|
def | __init__ (self) |
|
def | fit (self, f, xData, yData, yErrs=None, lowerBounds=None, upperBounds=None) |
|
def | getFitParameterCount (self) |
|
def | getFitParameter (self, index) |
|
def | getFitParameterVariance (self, index) |
|
def | getFitParameterStandardDeviation (self, index) |
|
def | getFitParameterCovariance (self, index1, index2) |
|
def | __eq__ (self, rhs) |
|
def | __ne__ (self, rhs) |
|
Helps fitting data to arbitrary functions, and handling the results.
Definition at line 12 of file Fit.py.
◆ __init__()
def MPCDAnalysis.Fit.Fit.__init__ |
( |
|
self | ) |
|
The constructor.
Definition at line 18 of file Fit.py.
◆ __eq__()
def MPCDAnalysis.Fit.Fit.__eq__ |
( |
|
self, |
|
|
|
rhs |
|
) |
| |
Returns whether this instance and `rhs` have the same state.
@throw TypeError
Throws if any argument is of the wrong type.
@param[in] rhs
The right-hand-side instance of this class.
Definition at line 407 of file Fit.py.
◆ __ne__()
def MPCDAnalysis.Fit.Fit.__ne__ |
( |
|
self, |
|
|
|
rhs |
|
) |
| |
Returns the negation of `self == rhs`.
@throw TypeError
Throws if any argument is of the wrong type.
@param[in] rhs
The right-hand-side instance of this class.
Definition at line 449 of file Fit.py.
◆ fit()
def MPCDAnalysis.Fit.Fit.fit |
( |
|
self, |
|
|
|
f, |
|
|
|
xData, |
|
|
|
yData, |
|
|
|
yErrs = None , |
|
|
|
lowerBounds = None , |
|
|
|
upperBounds = None |
|
) |
| |
Fits the given data to the given fit function `f`.
After calling this, any previous fits with this instance, and the
corresponding fit results, are discarded.
@throw TypeError
Throws if any argument is of the wrong type.
@throw ValueError
Throws if `xData`, `yData`, and `yErrs` (if not `None`) have
different lengths.
@throw ValueError
Throws if `lowerBounds` or `upperBounds` has the wrong length,
or invalid values.
@param[in] f
The function to fit to; it must be supplied as a callable
object, taking, as its first parameter, an instance of
`numpy.ndarray` containing all the independent variable
values to evaluate the fit function for. This callable must
then return an instance of `numpy.ndarray` containing, in the
same order, the fit function values corresponding to the
elements in the first argument.
Any further arguments this callable takes are assumed to be
fit parameters that will be optimized for.
@param[in] xData
An iterable containing the independent variable values to fit
with.
@param[in] yData
An iterable containing the target values, which the fit
should approach as much as possible. The order must
correspond to `xData`.
@param[in] yErrs
An iterable containing, in an order corresponding to `yData`,
the uncertainties (one standard deviation error) on the
elements on `yData`.
@param[in] lowerBounds
Either `None` to have no lower bounds on the fitting
parameters, or a `list`, the length of which corresponds to
the number of fitting parameters, where each value represents
the lower bound for the corresponding fitting parameter.
Values of `None` in this list correspond to no bound for that
parameter.
@param[in] upperBounds
As in `lowerBounds`, except that upper bounds are specified.
Definition at line 70 of file Fit.py.
◆ getBestOutOfMultipleIndependentDataFits()
def MPCDAnalysis.Fit.Fit.getBestOutOfMultipleIndependentDataFits |
( |
|
f, |
|
|
|
dataSet, |
|
|
|
comparator |
|
) |
| |
|
static |
Independently fits multiple sets of data to the given fit function `f`,
and returns the best fit, as determined by `comparator`.
This function returns the equivalent to the result of the following
procedure:
First, let `results = multipleIndependentDataFits(f, dataSet)`.
Then, if `results` is empty, return `None`. Otherweise, start by calling
the first result in the list the `best` result, and iterate through all
other results, with iteration variable `currentResult`. For each
iteration, call `comparator(best, currentResult)`; if it returns `True`,
let `best = currentResult`.
After having completed all iterations, return `best`.
@throw TypeError
Throws if any argument is of the wrong type.
@throw ValueError
Throws if any argument has an invalid value.
@param[in] f
The function to fit to; it must satisfy the conditions for
the `f` argument to `fit`.
@param[in] dataSet
An iterable, with elements being lists of length `3`; the
list elements will be passed as the `xData`, `yData`, and
`yErrs` parameters to `fit`, and accordingly need to satisfy
the conditions there.
@param[in] comparator
The callable used to compare two fits; see the main body
of this function documentation for details.
Definition at line 378 of file Fit.py.
◆ getFitParameter()
def MPCDAnalysis.Fit.Fit.getFitParameter |
( |
|
self, |
|
|
|
index |
|
) |
| |
Returns the parameter estimate for the parameter with the given `index`.
@throw RuntimeError
Throws if `fit` has not been called successfully previously.
@throw TypeError
Throws if any argument is of the wrong type.
@throw ValueError
Throws if `index` is out of bounds.
@param[in] index
The index of the fit parameter, which must be a non-negative
`int` that is smaller than `getFitParameterCount()`.
Definition at line 195 of file Fit.py.
◆ getFitParameterCount()
def MPCDAnalysis.Fit.Fit.getFitParameterCount |
( |
|
self | ) |
|
Returns the number of fit parameters used in the last successful call
to `fit`.
@throw RuntimeError
Throws if `fit` has not been called successfully previously.
Definition at line 172 of file Fit.py.
◆ getFitParameterCovariance()
def MPCDAnalysis.Fit.Fit.getFitParameterCovariance |
( |
|
self, |
|
|
|
index1, |
|
|
|
index2 |
|
) |
| |
Returns the covariance of the parameter estimates for the parameter with
the given indices, if such a covariance is available, or `numpy.inf` if
no coviariance estimate was possible.
@throw RuntimeError
Throws if `fit` has not been called successfully previously.
@throw TypeError
Throws if any argument is of the wrong type.
@throw ValueError
Throws if either `index1` or `index2` is out of bounds.
@param[in] index1
The index of one of the fit parameters, which must be a
non-negative `int` that is smaller than
`getFitParameterCount()`.
@param[in] index2
The index of one of the fit parameters, which must be a
non-negative `int` that is smaller than
`getFitParameterCount()`.
Definition at line 288 of file Fit.py.
◆ getFitParameterStandardDeviation()
def MPCDAnalysis.Fit.Fit.getFitParameterStandardDeviation |
( |
|
self, |
|
|
|
index |
|
) |
| |
Returns the standard deviation of the parameter estimate for the
parameter with the given `index`, if such a standard deviation is
available, or `numpy.inf` if no standard deviation estimate was
possible.
@throw RuntimeError
Throws if `fit` has not been called successfully previously.
@throw TypeError
Throws if any argument is of the wrong type.
@throw ValueError
Throws if `index` is out of bounds.
@param[in] index
The index of the fit parameter, which must be a non-negative
`int` that is smaller than `getFitParameterCount()`.
Definition at line 260 of file Fit.py.
◆ getFitParameterVariance()
def MPCDAnalysis.Fit.Fit.getFitParameterVariance |
( |
|
self, |
|
|
|
index |
|
) |
| |
Returns the variance of the parameter estimate for the parameter with
the given `index`, if such a variance is available, or `numpy.inf` if no
variance estimate was possible.
@throw RuntimeError
Throws if `fit` has not been called successfully previously.
@throw TypeError
Throws if any argument is of the wrong type.
@throw ValueError
Throws if `index` is out of bounds.
@param[in] index
The index of the fit parameter, which must be a non-negative
`int` that is smaller than `getFitParameterCount()`.
Definition at line 227 of file Fit.py.
◆ multipleIndependentDataFits()
def MPCDAnalysis.Fit.Fit.multipleIndependentDataFits |
( |
|
f, |
|
|
|
dataSet |
|
) |
| |
|
static |
Independently fits multiple sets of data to the given fit function `f`.
@throw TypeError
Throws if any argument is of the wrong type.
@throw ValueError
Throws if any argument has an invalid value.
@param[in] f
The function to fit to; it must satisfy the conditions for
the `f` argument to `fit`.
@param[in] dataSet
An iterable, with elements being lists of length `3`; the
list elements will be passed as the `xData`, `yData`, and
`yErrs` parameters to `fit`, and accordingly need to satisfy
the conditions there.
@return Returns a list of dictionaries, in the order that corresponds
to the order in `dataSet`; each dictionary contains the
following elements:
- `data`, the list returned while iterating `dataSet`
- `fit`, an instance of this class, on which `fit` has been
called with the given `f` and the `data` elements, as
described in the documentation for the `dataSet` parameter.
Definition at line 333 of file Fit.py.
The documentation for this class was generated from the following file: