Fitting Function¶
FittingFunction Class¶
-
class
eddington.fitting_function_class.
FittingFunction
(fit_func: Callable, n: int, name: str, syntax: Optional[str] = None, a_derivative: Optional[Callable] = None, x_derivative: Optional[Callable] = None, save: dataclasses.InitVar = True)¶ Fitting function class.
This class wraps up a callable which gets 2 parameters:
a
- An array with the parameters of the function.x
- The sample data to be fit.
Our main goal is to find the best suitable
a
that match givenx
values to giveny
values.Parameters: - fit_func (callable) – The actual fitting function.
- n (int) – Number of parameters. the length of “a” in fit_func.
- name (str) – The name of the function.
- syntax (str) – The syntax of the fitting function
- a_derivative (callable) – a function representing the derivative of fit_func according to the “a” array
- x_derivative (callable) – a function representing the derivative of fit_func according to x
- save (bool) – Should this function be saved in the
FittingFunctionsRegistry
-
active_parameters
¶ Property of number of active parameters.
Returns: number of active parameters (aka, unfixed). Return type: int
-
assign
(a: Union[List[float], <sphinx.ext.autodoc.importer._MockObject object at 0x7fb3a81300d0>]) → eddington.fitting_function_class.FittingFunction¶ Assign the function parameters.
Parameters: a (list of floats or np.ndarray) – Parameters to be assigned Returns: self Return type: FittingFunction
-
clear_fixed
() → eddington.fitting_function_class.FittingFunction¶ Clear all fixed parameters.
Returns: self Return type: FittingFunction
-
fix
(index, value)¶ Fix parameter with predefined value.
Parameters: - index (int) – The index of the parameter to fix. Starting from 0
- value (float) – The value to fix
Returns: self
FittingFunction
Raises: FittingFunctionRuntimeError – Raised when trying to fix a non existing parameter.
-
title_name
¶ Function name in title format.
Returns: title name Return type: str
-
unfix
(index)¶ Unfix a fixed parameter.
Parameters: index (int) – The index of the parameter to unfix Returns: self FittingFunction
fitting_function decorator¶
-
fitting_function_class.
fitting_function
(name: Optional[str] = None, syntax: Optional[str] = None, a_derivative: Optional[Callable[[<sphinx.ext.autodoc.importer._MockObject object at 0x7fb3a81278d0>, Union[<sphinx.ext.autodoc.importer._MockObject object at 0x7fb3a8127910>, float]], <sphinx.ext.autodoc.importer._MockObject object at 0x7fb3a8127f50>]] = None, x_derivative: Optional[Callable[[<sphinx.ext.autodoc.importer._MockObject object at 0x7fb3a8130290>, Union[<sphinx.ext.autodoc.importer._MockObject object at 0x7fb3a8130210>, float]], Union[<sphinx.ext.autodoc.importer._MockObject object at 0x7fb3a8130610>, float]]] = None, save: bool = True) → Callable[[Callable[[<sphinx.ext.autodoc.importer._MockObject object at 0x7fb3a8130910>, Union[<sphinx.ext.autodoc.importer._MockObject object at 0x7fb3a8130950>, float]], Union[<sphinx.ext.autodoc.importer._MockObject object at 0x7fb3a8130a10>, float]]], eddington.fitting_function_class.FittingFunction]¶ Wrapper making a simple callable into a
FittingFunction
.Parameters: - n (int) – Number of parameters. The length of parameter
a
of the fitting function. - name (str) – The name of the function.
- syntax (str) – The syntax of the fitting function.
- a_derivative (callable) – a function representing the derivative of the fitting function according to the “a” parameter array
- x_derivative – a function representing the derivative of the fitting function according to x
- save (bool) – Should this function be saved in the
FittingFunctionsRegistry
Returns: a fitting function
Return type: - n (int) – Number of parameters. The length of parameter