Finding coefficients and bias term for equation y = (x-B)*A
5 views (last 30 days)
Show older comments
This is my equation;
Y= (X-B)*A ----------(1) ,
moving RHS side to LHS it will become
Y-(X-B)*A = 0 ----------(2)
Y is 1*3 matrix, A is 3*3 matrix, X is 1*3 matrix, B is 1*3 matrix. expressed as
Y = [Yx Yy Yz];
X = [Xx Xy Xz];
I have Y and X values i want to calulate A,B that is
A = [A11 A12 A13; A21 A22 A23; A31 A32 A33];
B = [b1 b2 b3];
Suppose I have 1000 different values in a 1*3 matrix of X and Y. And for these values, I want to calculate a single value of A and B so that equation (2) is satisfied. you may take some coefficiant values zero.......
how should i calculate this please help........
Thank you in advance................
3 Comments
John D'Errico
on 18 Dec 2023
Edited: John D'Errico
on 18 Dec 2023
Your question has no answer. In fact, there are multiple flaws with your request.
First, MINIMUM? Minimum implies minus infinity is your goal. And since that is a matrix equation, your question has no meaning. Perhaps you mean something like the norm of the result is minimum, so as close to zero as possible. That has more of an answer, but still a serious flaw.
I would also add that you have posed TWO distinct equations. So, in the subject, you say Y=A*X+B. But in your question, you have several places said Y=(X-B)*A. Which is it? Should we guess? However, the shape of your vectors and the matrices would make the form Y=A*X+B meaningless, since the matrix-vector products will not conform. So I can assume the subject heading is simply wrong.
Next, even assuming answers to the abouve relatively minor points, there is still the impossible question to answer, in that your question has no answer, or that is has infinitely many answers, all of which are different but none are any better than the rest.
You have given 3 pieces of information, so effectively 3 data points. But you want to solve for 9 coefficients. And that is impossible to do in any unique way.
Answers (1)
John D'Errico
on 18 Dec 2023
Edited: John D'Errico
on 18 Dec 2023
As my comment stated, this question is impossible to answer in any meaningful way. That is, given 1x3 vectors X and Y, can you find a 3x3 matrix A and a 1x3 vector B, such that
Y = (X-B)*A
is as close to all zeros as possible. Effectively, you are probably asking to solve for A and B such that norm(Y-(X-B)*A) is as close to zero as possible. Anything else is meaningless.
Given that, can we solve trivially for a 3x3 matrix and a vector B? Well, yes. But even this is meaningless, as there are infinitely many solutions, all of which are EXACT. For example, I'll pick some random numbers for X and Y.
format long g
X = randn(1,3)
Y = randn(1,3)
Now I'll choose B as the all zero vector. We don't need B at all.
B = zeros(1,3)
FInally, A is given simply as
A = (X-B)\Y
Does it work? Yes. Trivially.
(X-B)*A
As you should see, this is exactly the value of the vector Y, so the difference will be identically zero. Actually, the difference may possibly be floating point trash, so a number on the order of eps.
norm(Y - (X-B)*A)
In this case, it was exactly zero, so I got lucky.
But there are infinitely many other solutions that we could have chosen, that would have been equally good. You should notice that A was mostly zeros itself. We don't even need 6 of the 9 unknown coefficients in A. And B was chosen in advance as all zeros. That should tell you how trivial and useless is this solution.
The real problem here is that you misunderstand something about matrices and linear algebra, even to ask this question. We can't know why you have posed this question, or what you were hoping it would solve.
0 Comments
See Also
Categories
Find more on Linear Least Squares 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!