amep.base.BaseFunction#
- class amep.base.BaseFunction(nparams: int)#
Bases:
object
Base class to fit a function to data.
- __init__(nparams: int) None #
Creats a BaseFunction object.
- Parameters:
nparams (int) – Number of parameters of the fit function.
Methods
__init__
(nparams)Creats a BaseFunction object.
f
(p, x)fit
(xdata, ydata[, p0, sigma, maxit, verbose])Fits the function self.f to the given data by using ODR (orthogonal distance regression).
generate
(x[, p])Returns the y values for given x values.
Attributes
Returns the fit errors for each parameter as an array.
keys
name
nparams
output
Returns an array of the optimal fit parameters.
Returns the dictionary of fit results including parameter names, parameter values, and fit errors.
- property errors: ndarray#
Returns the fit errors for each parameter as an array.
- Returns:
Fit errors.
- Return type:
np.ndarray
- fit(xdata: ndarray, ydata: ndarray, p0: list | None = None, sigma: ndarray | None = None, maxit: int | None = None, verbose: bool = False) None #
Fits the function self.f to the given data by using ODR (orthogonal distance regression).
- Parameters:
xdata (np.ndarray) – x values.
ydata (np.ndarray) – y values.
p0 (list or None, optional) – List of initial values. The default is None.
sigma (np.ndarray or None, optional) – Absolute error for each data point. The default is None.
maxit (int, optional) – Maximum number of iterations. The default is 200.
verbose (bool, optional) – If True, the main results are printed. The default is False.
- Return type:
None.
- generate(x: ndarray, p: list | None = None) ndarray #
Returns the y values for given x values.
- Parameters:
x (np.ndarray) – x values.
p (list, optional) – List of parameters. The default is None.
- Returns:
y – f(x)
- Return type:
np.ndarray
- property params: ndarray#
Returns an array of the optimal fit parameters.
- Returns:
Fit parameter values.
- Return type:
np.ndarray
- property results: dict#
Returns the dictionary of fit results including parameter names, parameter values, and fit errors.
- Returns:
Fit results.
- Return type:
dict