estimated_covariance_matrix_inverse¶
- sofia_redux.toolkit.resampling.estimated_covariance_matrix_inverse(phi, error, weights, rank=None)[source]¶
Calculates covariance matrix inverse of fit coefficients from mean error.
An estimate to the covariance of fit parameters is given by:
\[\Sigma = \frac{N}{N - M} \bar{\sigma}^2 (\Phi^T W \Phi)^{-1}\]where
N
are the number of samples used in the fit, \(M\) are the number of lost degrees of freedom, \(W\) are theweights
applied to the samples during the fit, and the estimated coefficients \(\hat{c}\) are used to fit \(y = \hat{c} \cdot \Phi + \sigma\) to the sample population \(y = c \cdot \Phi + \epsilon\). The weighted mean of the squarederror
(\(\bar{\sigma}^2\)) is given by:\[\bar{\sigma}^2 = \frac{\sum_{i=1}^{N}{w_i e_i^2}} {\sum_{i=1}^{N}{w_i}}\]The final returned matrix is \(\Sigma^{-1}\).
- Parameters:
- phinumpy.ndarray (nterms, N)
The polynomial terms for each of the N data samples.
- errornumpy.ndarray (N,)
The 1-sigma errors or residuals to the fit.
- weightsnumpy.ndarray (N,)
The weighting of each sample in the fit, not including any error weighting.
- rankint or float, optional
The matrix rank of \(\Phi^T W \Phi\), optionally passed in for speed if pre-calculated.
- Returns:
- covariance_inversenumpy.ndarray (nterms, nterms)
The inverse covariance matrix.