MATLAB Function Reference |

Least squares solution in the presence of known covariance

**Syntax**

**Description**

```
x = lscov(A,b,V)
```

returns the vector `x`

that solves `A*x = b + e`

where `e`

is normally distributed with zero mean and covariance `V`

. Matrix `A`

must be `m`

-by-`n`

where `m > n`

. This is the over-determined least squares problem with covariance `V`

. The solution is found without inverting `V`

.

```
[x,dx] = lscov(A,b,V)
```

returns the standard errors of `x`

in `dx`

. The standard statistical formula for the standard error of the coefficients is:

mse = B'*(inv(V)-inv(V)*A*inv(A'*inv(V)*A)*A'*inv(V))*B./(m-n) dx = sqrt(diag(inv(A'*inv(V)*A)*mse))

**Algorithm**

The vector `x`

minimizes the quantity `(A*x-b)'*inv(V)*(A*x-b)`

. The classical linear algebra solution to this problem is

but the `lscov`

function instead computes the QR decomposition of `A`

and then modifies `Q`

by `V`

.

**See Also**

The arithmetic operator `\`

**Reference**

[1] Strang, G., *Introduction to Applied Mathematics*, Wellesley-Cambridge,
1986, p. 398.

ls | lsqnonneg |