Linfit - import numpy as np import scipy.special as ss def linfit(y x=None y_unc=None Fits a line to 2D data optionally with errors in y The method

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
import numpy as np import scipy.special as ss def linfit(y, x=None, y_unc=None): ''' Fits a line to 2D data, optionally with errors in y. The method is robust to roundoff error. Parameters ---------- y: ndarray Ordinates, any shape. x: ndarray Abcissas, same shape. Defaults to np.indices(y.length)) y_unc: ndarray Uncertainties in y. If scalar or 1-element array, applied uniformly to all y values. [NOT IMPLEMENTED YET!] Must be positive. Returns ------- a: scalar 0 Fitted intercept b: scalar 1 Fitted slope a_unc: scalar 2 Uncertainty of fitted intercept b_unc: scalar 3 Uncertainty of fitted slope chisq: scalar 4 Chi-squared prob: scalar 5 Probability of finding worse Chi-squared for this model with these uncertainties. covar: ndarray 6 Covariance matrix: [[a_unc**2, covar_ab], [covar_ab, b_unc**2]] yfit: ndarray 7 Model array calculated for our abcissas Notes ----- If prob > 0.1, you can believe the fit. If prob > 0.001 and the errors are not Gaussian, you could believe the fit. Otherwise do not believe it.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/09/2009 for the course AST 4762 taught by Professor Harrington during the Fall '09 term at University of Central Florida.

Page1 / 3

Linfit - import numpy as np import scipy.special as ss def linfit(y x=None y_unc=None Fits a line to 2D data optionally with errors in y The method

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online