linreg

linea.linreg(X, flux, error)[source] [edit on github]

Least squares linear regression.

We solve for the least-squares estimators \(\hat{\beta}\),

\[\hat{\beta} = ({\bf X}^{\rm T} {\bf N}^{-1} {\bf X})^{-1} {\bf X}^{\rm T} {\bf N}^{-1} f.\]

Uncertainties on each of the least-squares estimators are computed with the pre-computed matrix inversion,

\[\sigma_{\hat{\beta}}^2 = ({\bf X}^{\rm T} {\bf N}^{-1} {\bf X})^{-1}.\]

We’ve defined the uncertainty matrix \(\bf N\),

\[{\bf N} = {\bf I_M} \sigma_f^2,\]

where \(\bf I_M\) is the identity matrix.

Parameters
Xndarray

Design matrix (concatenated column vectors)

fluxndarray

Flux measurements (row vector)

errorndarray

Uncertainties on each flux measurement (row vector)

Returns
betasndarray

Least squares estimators \(\hat{\beta}\)

covndarray

Covariance matrix for the least squares estimators \(\sigma_{\hat{\beta}}^2\)