Fitfunctions¶
The builtin fitfunctions all follow this form:
-
mre.
f_fitfunction
(k, arg1, arg2, ...)¶ Parameters: - k (array_like) – Independent variable as first argument. If an array is provided, an array of same length will be returned where the function is evaluated elementwise
- args (float) – Function arguments
Return type: float or array
Example
import numpy as np import matplotlib.pyplot as plt import mrestimator as mre # evaluate exp(-1) via A e^(-k/tau) print(mre.f_exponential(1, 1, 1)) # test data rk = mre.coefficients(mre.simulate_branching(m=0.9, h=10, numtrials=10)) # pass builtin function to fit f = mre.f_exponential_offset m = mre.fit(rk, f) # provide an array as function argument to evaluate elementwise # this is useful for plotting xargs = np.array([0, 1, 2, 3]) print(m.popt) # unpack m.popt to provide all contained arguments at once print(f(xargs, *m.popt)) # get a TeX string compatible with matplotlib's legends print(mre.math_from_doc(f))
-
mrestimator.
f_complex
(k, tau, A, O, tauosc, B, gamma, nu, taugs, C)[source]¶ \(|A| e^{-k/\tau} + B e^{-(k/\tau_{osc})^\gamma} \cos(2 \pi \nu k) + C e^{-(k/\tau_{gs})^2} + O\)
-
mrestimator.
default_fitpars
(fitfunc)[source]¶ Called to get the default starting parameters for the built-in fitfunctions that are used to initialise the fitting routine. Timelike values specified here were derived assuming a timescale of miliseconds.
Parameters: fitfunc (callable) – The builtin fitfunction Returns: pars (~numpy.ndarray) – The default parameters of the given function, 2d array for multiple sets of initial conditions.