1
$\begingroup$

I have $q$ measurements with $p$ different excitations.

In one special case, they might be equal in length. For example, I might have 12 measurements ($q=12$) with three excitations each ($p = 3$), like so:

a0 = {1, 2, 3}
a1 = {0, 4, 1}
a2 = {4, 4, 4}
a3 = {2, 1, 1}
....
a11 = {3, 1, 5}

which results in 12 different observations/measurements — in this case also with three elements each (q = 3):

b0 = {17, 22, 10}
b1 = {21, 19, 13}
b2 = {40, 48, 20}
b3 = {14, 17, 6}
....
b11 = {22, 34, 11}

I would like to know the p x q (in this case 3 x 3) matrix Xfits best with least squares fit.

$\qquad b_n==X\cdot a_n$ for $n=0\dots11$

Is there's a simple way to get this estimation in Mathematica?

I also have some additional knowledge of the matrix. The elements satisfy

X[[i, j]] == X[[j, i]]

Is there is a way to make the least square fit aware of the symmetry?

I think this is some sort of multivariate regression, but I don't get the right starting point.

$\endgroup$
  • 1
    $\begingroup$ I think you are looking for LeastSquares. $\endgroup$ – MarcoB Apr 5 '19 at 21:40
  • $\begingroup$ MarcoB, thank you for the hint. LeastSquare does the job. However - it can not handle the knowledge of equal coefficients. $\endgroup$ – Robert James Apr 7 '19 at 6:00
6
$\begingroup$

One possibility is to state this as a minimization problem:

a = RandomInteger[{0, 10}, {3, 11}];
b = RandomInteger[{0, 10}, {3, 11}];
xSym = {{x[1, 1], x[1, 2], x[1, 3]}, {x[1, 2], x[2, 2], 
    x[2, 3]}, {x[1, 3], x[2, 3], x[3, 3]}};
Minimize[Norm[b - xSym.a, "Frobenius"], Union[Flatten[xSym]]] // N

Here a and b are your data matrices, xSym is the symmetric 3 by 3 unknown, and the final line minimizes the norm of b - xSym.a. You could also use other norms:

NMinimize[Norm[b - xSym.a, 2], Union[Flatten[xSym]]]

or

NMinimize[Norm[b - xSym.a, 1], Union[Flatten[xSym]]]
$\endgroup$
  • $\begingroup$ Thank you. Works exactly as indented. $\endgroup$ – Robert James Apr 7 '19 at 5:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.