Content
Here we discuss how to apply fit to data using absolute errors, get fit parameters with errors, estimate fit quality.
Data
exp=cxif5315:run=169
Processing script
cxif5315/proc-cxif5315-r0169-peaks-from-file-v4.py
essential code
from scipy.optimize import curve_fit from scipy.stats import chi2 xn = np.array([pk.x/L for pk in sp.lst_equ_evt_peaks], dtype=np.double) yn = np.array([pk.y/L for pk in sp.lst_equ_evt_peaks], dtype=np.double) en = np.array([max(pk.rsigma,pk.csigma)*sp.PIXEL_SIZE/L for pk in sp.lst_equ_evt_peaks], dtype=np.double) p0 = [-3.2,-16.0] # phi, beta angle central values popt, pcov = curve_fit(funcy, xn, yn, p0, en, absolute_sigma=True) sp.fib_chi2 = np.sum(((funcy(xn, *popt) - yn) / en)**2) sp.fib_ndof = len(xn) - 1 sp.fib_prob = chi2.sf(sp.fib_chi2, sp.fib_ndof, loc=0, scale=1)
Parameters
Distribution of parameters for peaks found by peak_finder_v2:
For 2-peak events fit does not have any freedom - curve can exactly be fitted to 3 points (including origin); chi2=0 and probability is always 1.
For >2-peak events chi2 and probability show some distribution.
References
Overview
Content Tools