How to find the vector b if we know the RMSE?
Show older comments
If we have two vectors given by:
a=[3,6,8,20,35,45];
b=[3.0343, 6.2725, 8.5846, 18.3781, 34.2025, 44.9699];
Then its Mean Square Error MSE and Root Mean Sqaure Error RMSE are given by:
MSE = mean((a-b).^2,2);
RMSE = sqrt(MSE);
But if we know MSE and RMSE and one of the vector namely 'a', then how to find the 2nd vector b?
Answers (2)
That's not possible. You have, in this case, 6 unknowns but only 1 equation.
1 Comment
Here's one simple solution for b:
a=[3,6,8,20,35,45];
RMSE=3.7;
b=a+RMSE;
rootMeanSquaredError = sqrt( mean((a-b).^2) ) %verify
There are infinitely many possible vectors b, for any given RMSE. And worse, they can have infinitely many possible shapes. This means it is flatly not possible to find a unique vector b that yields a given RMSE. Sorry.
Do you want proof?
a=[3,6,8,20,35,45];
b=[3.0343, 6.2725, 8.5846, 18.3781, 34.2025, 44.9699];
For example consider this simple vector b1:
n = length(a);
RMSEfun = @(b) sqrt(sum((a - b).^2/n));
syms x
rmsetarget = 1;
b1 = sym(a); b1(1) = x; % I will change only the first elememt of b
x1 = vpasolve(RMSEfun(b1) == rmsetarget,x)
b1 = double(subs(b1,x,x1))
RMSEfun(b1)
So by trivially changing one arbitrary element of a, I found a new vector b that yields exactly the desired RMSE. I could have perturbed ANY element and gotten the same result.
b2 = sym(a); b2(4) = x; % I will change only the first elememt of b
x2 = vpasolve(RMSEfun(b2) == rmsetarget,x)
b2 = double(subs(b2,x,x2))
RMSEfun(b2)
Or, I might have chosen b in a different way.
b3 = sym(a); b3 = b3*x; % I will change EVERY element of b, proportionally
x3 = vpasolve(RMSEfun(b3) == rmsetarget,x)
b3 = double(subs(b3,x,x3))
RMSEfun(b3)
Again, there are infinitely many solutions. I chose only 3 trivial examples.
10 Comments
Sadiq Akbar
on 12 Jan 2023
Sadiq Akbar
on 12 Jan 2023
John D'Errico
on 12 Jan 2023
Edited: John D'Errico
on 12 Jan 2023
I'm sorry, but NO.
You have a matrix C, and a vector a.
size(C)
ans =
100 6
size(a)
ans =
1 6
For every row of C, you subtract the vector a. And then compute an RMSE against each row of C. That allowed you to compute an RMSE for each row.
Now you tell us that you want to change the RMSE by some constant amount.
The matrix C has 100*6 = 600 elements. Now you want to infer what the =value of all 600 unknown elements, having specified only 100 numbers?
You did not think about my answer, did you? Now you have 600 unknowns. And you have 100 equations. Is 600 SIGNIFICANTLY greater than 100?
Even if you have only 1 more unknown than you have equations, you cannot solve the problem uniquely. But with 500 more unknowns than you have equations, you somehow think it is possible to solve this problem?
Let me say it again. YOU CANNOT INFER THE VALUE OF 600 UNKNOWNS FROM ONLY 100 PIECES OF INFORMATION.
Just wanting a problem to have a solution is not sufficient for it to have a solution. Just wanting a solution very badly does not make the solution suddenly possible.
Sadiq Akbar
on 13 Jan 2023
Torsten
on 13 Jan 2023
I think you have to look up the formula for RMSE. Where is the sum in your expression RMSE=sqrt((a-b)^2/N) ?
Sadiq Akbar
on 13 Jan 2023
Torsten
on 13 Jan 2023
Isn't that?
No.
N * RMSE^2 = (x1-y1)^2 + (x2-y2)^2 + (x3-y3)^2 + (x4-y4)^2
Now show me how you want to solve uniquely for y1, y2, y3 and y4 given N, RMSE and x1, x2, x3 and x4.
As noted several times by other participants, you have only 1 equation (the one above), but 4 unknowns.
As noted several times by other participants, you have only 1 equation (the one above), but 4 unknowns.
Yes. In fact the equation is that of a hypersphere of radius sqrt(N)*RMSE and centered at a. Any point b on the surface of this hypersphere is a solution.
John D'Errico
on 13 Jan 2023
Edited: John D'Errico
on 13 Jan 2023
I will keep on saying it. You do not have sufficient information to solve for the unknowns. It is one equation only. And you have multiple unknowns. In your last example, we have:
a = [3,6,8,20];
With N and RMSE given, we have
N = 4;
RMSE = 1; % I'll just pick a number for RMSE
syms y [1,4]
N * RMSE^2 == sum((a - y).^2)
Do you recognize this as the equation of a sphere in 4 dimensions? If not, you should. The center of the sphere is the point a=[3 6 8 20], and the square of the radius is given here as 4=2^2.
But ANY point on the surface of that sphere is a solution to your problem. ANY point. Need I repeat that? ANY POINT. How many points lie on the surface of a sphere? (Infinitely many.)
There is NO solution to your question. You cannot solve for the unknown vector (here y or b as you prefer.) You can keep on insisting there is a solution, but the mathematics says you are completely wrong. There are infinitely many solutions and there is no way to choose any specific solution, beyond saying the solution lies SOMEWHERE on the surface of that sphere.
Sadiq Akbar
on 14 Jan 2023
Categories
Find more on Particle & Nuclear Physics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!