LinearFit
- class jwst.ami.leastsqnrm.LinearFit(dependent_variable, inverse_covariance_matrix, independent_variable)[source]
Bases:
objectPerform a general least-squares fit of a linear model using numpy matrix inversion.
Uncertainties in the dependent variables (but not in the independent variables) can be taken into account. All inputs have to be numpy matrices.
Math is based on Press’
Numerical Recipes p661 : Section 15.2 Fitting Data to a Straight Line
Numerical Recipes p671 : Section 15.4 General Linear Least Squares
Code is based on an early yorick implementation by Damien Segransan (University of Geneva) Python implementation and tools by Johannes Sahlmann 2009-2017 (University of Geneva, European Space Agency, STScI/AURA)
- Parameters:
- dependent_variablendarray (1xN)
Dependent_variables of the linear equation system (N equations, M unknown coefficients)
- inverse_covariance_matrixndarray (NxN)
Inverse covariance matrix corresponding to the dependent_variable. i.e. data weights proportional to 1/sigma**2 where sigma=uncertainty
- independent_variablendarray (MxN)
The independent_variables that are multiplied by the unknown coefficients
- Attributes:
- pndarray
Coefficients of the solution
- p_formal_uncertaintyndarray
Formal uncertainty of the coefficients
- p_formal_covariance_matrixndarray
Formal covariance matrix of the coefficients (not rescaled)
- p_normalised_uncertaintyndarray
Normalised uncertainty (chi2 = 1) of the coefficients
- p_normalised_covariance_matrixndarray
Normalised covariance matrix of the coefficients (rescaled to yield chi2=1)
- p_correlation_matrixndarray
Coefficient correlation matrix
fitndarrayPerform the linear fit.
- residualsndarray
Observed - Calculated (O-C) residuals
- chi2float
Chi-square value of the best fit
Methods Summary
fit()Perform the linear fit.
Methods Documentation