class BaseModel( object ) | Source |
---|
BaseModel implements the common parts of simple Models.
A simple model is a function in x with parameters p : f(x:p). The variable x is an array of points in a space of one or more dimensions; p can have any length, including 0 i.e. the model has no parameters.
The result of the function for certain x and p is given by model.result( x, p )
The partial derivatives of f to p (df/dp) is given by model.partial( x, p ) Some fitters make use of the partials
The derivative of f to x (df/dx) is given by model.derivative( x, p )
BaseModel checks parameters for positivity and nonzero-ness, if such is indicated in the model itself.
BaseModel also implements the numerical calculation of the (partial) derivatives to be used when they are not given in the model definition itself.
Attributes
-
npbase : int
number of params in the base model -
ndim : int
number of dimensions (parallel streams) of input. (default : 1) -
priors : list of Prior
pertaining to each of the parameters of the model.
If the list is shorter than the number of parameters, the last one is repeated. -
posIndex : list of int
list of indices indication positive-definite parameters. -
nonZero : list of int
list of parameters that need a warning when they are equal to zero.
Warnings will only be issued once. Values are replaced by self.tiny -
tiny : float
very small value, replacing zero valued when found on NonZero.
(default : 1e-20) -
deltaP : array_like
(list of) width(s) for numerical partial calculation. (default : 0.00001) -
parNames : list of str
list of parameter names. (default : "parameter_k") -
Author : Do Kester
BaseModel( nparams=0, ndim=1, copy=None, posIndex=[], nonZero=[], **kwargs ) |
---|
BaseModel Constructor.
Parameters
- nparams : int
Number of parameters in the model (default: 0) - ndim : int
Number of dimensions of the input (default: 1) - copy : BaseModel
to be copied - posIndex : list of int
indices of parameters that need to be > 0 - nonZero : list of int
indices of parameters that cannot be zero.
they are replaced by self.tiny kwargs
for internal use.
result( xdata, param ) |
---|
Parameters
- xdata : array_like
values at which to calculate the result - param : array_like
values for the parameters.
partial( xdata, param, parlist=None ) |
---|
Parameters
- xdata : array_like
values at which to calculate the result - param : array_like
values for the parameters. - parlist : None or array_like
indices of active parameters
checkParameter( param ) |
---|
Parameters
- param : array_like
values for the parameters.
checkPositive( param ) |
---|
Parameters
- params : array_like
values for the parameters
checkZeroParameter( param ) |
---|
Parameters
- params : array_like
values for the parameters
isDynamic( ) |
---|
isModifiable( ) |
---|
shortName( ) |
---|
derivative( xdata, param ) |
---|
It is a numeric derivative as the analytic derivative is not present in the model.
Parameters
- xdata : array_like
values at which to calculate the derivative - param : array_like
values for the parameters. (default: model.parameters)
setPrior( kpar, prior=None, **kwargs ) |
---|
The prior (by default UniformPrior) is appended when kpar is equal to np, the length of the existing list of priors. It replaces the prior when kpar < np and it generates an error when kpar > np
Parameters
- kpar : int
parameter number. - prior : Prior
prior for the parameter - kwargs : dict
attributes to be passed to the prior
Raises
IndexError
when kpar is larger than the length of priors list already present
hasPriors( isBound=True ) |
---|
Parameters
- isBound : bool
Also check if the prior is bound.
getPrior( kpar ) |
---|
Parameters
- kpar : int
parameter number.
basePrior( kpar ) |
---|
Parameters
- kpar : int
parameter number.
getParameterName( kpar ) |
---|
Parameters
- kpar : int
parameter number.
baseParameterName( kpar ) |
---|
Parameters
- kpar : int
parameter number.
getParameterUnit( kpar ) |
---|
Parameters
- kpar : int
parameter number.
baseParameterUnit( kpar ) |
---|
Parameters
- kpar : int
parameter number.
hasLimits( fitindex=None ) |
---|