[SciPy-User] [SciPy-user] scipy.odr - Correct form of covx, covy matrix

Robert Kern robert.kern@gmail....
Tue Feb 14 08:29:17 CST 2012

```On Tue, Feb 14, 2012 at 02:38, Elfnor <elfnor@gmail.com> wrote:

> I am trying to solve a generalised least squares problem of the form A*x = b
> where A is the problem design matrix and b is a vector of correlated
> observations with covariance V. V is not diagonal.
>
> That is find x that minimizes (b - A*x)'*inv(V)*(b - A*x) similar to the
> matlab function lscov.

I think you can distribute the inv(V) by doing a Cholesky
factorization, then doing a Cholesky-solve on both A and b, then doing
a linear solve on the transformed A and b.

from scipy import linalg

cho = linalg.cho_factor(V)
Ac = linalg.cho_solve(cho, A)
bc = linalg.cho_solve(cho, b)
x = linalg.solve(Ac, bc)

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
```