class FixedModel( BaseModel ) | Source |
---|
A FixedModel is a BaseModel where some parameters are permanently fixed.
A parameter can be fixed either with a constant float value or more dynamically, with another Model. The parameters of this latter model also appear as parameters of the FixedModel.
The methods result (f(x:p)) and partial (df/dp) are calculated in here. Unfortunately the methods derivative (df/dx) is model dependent. It is reset to numDerivative.
Examples
m1 = PolynomialModel( 1 )
m1 += SineModel()
print( m1.npchain ) # number of params: 2 + 3
5
fixed = { 0: 1.0, 1: m1 }
em = EtalonModel( fixed=fixed )
print( em.npbase, em.npmax, em.npchain ) # ( 4 - 2 ) + 5
7 9 7
print( em )
Attributes
- npmax : int
maximum number of parameters of the simple (not-fixed) model - fixed : dictionary of {int:float|Model}
int index of parameter to fix permanently. Default None.
float value for the fixed parameter.
Model model to replace the parameter
Attribute fixed can only be set in the constructor. - parlist : array_like or None
list of active (not-fixed) indices. None is all. - mlist : list of Model
list of parameter indices which are replaced by a Model in fixed.
Attributes from BaseModel
npbase, ndim, priors, posIndex, nonZero, tiny, deltaP, parNames
Author Do Kester
FixedModel( nparams=0, ndim=1, copy=None, fixed=None, names=None, **kwargs ) |
---|
FixedModel 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 - fixed : dictionary of {int:float|Model}
int index of parameter to fix permanently. Default None.
float value for the fixed parameter.
Model model to replace the parameter
Attribute fixed can only be set in the constructor. - names : list of string
names for the parameters - kwargs for BaseModel :
posIndex, nonZero
copy( ) |
---|
select( params ) |
---|
Parameters
- params : array of float
parameters of the head model
selectNames( names ) |
---|
Parameters
- names : list of string
parameter names of the head model
result( xdata, param ) |
---|
Parameters
- xdata : array_like
values at which to calculate the result - params : array_like
values for the parameters.
expand( xdata, param ) |
---|
partial( xdata, param ) |
---|
Parameters
- xdata : array_like
values at which to calculate the result - params : array_like
values for the parameters.
numPartial( xdata, params, parlist=None ) |
---|
Parameters
- xdata : array_like
values at which to calculate the result - params : array_like
values for the parameters; default is self.parameters - parlist : array_like
list of indices active parameters (or None for all)
basePartial( xdata, param, parlist=None ) |
---|
Parameters
- xdata : array_like
values at which to calculate the result - param : array_like
values for the parameters. - parlist : array_like
list of indices active parameters (or None for all)
derivative( xdata, param ) |
---|
It is a numeric derivative as the analytic derivative is not present in the model.
If fixed
contains a Model, the derivative cannot be constructed
from the constituent models. Use numDerivative
instead.
Parameters
- xdata : array_like
values at which to calculate the derivative - param : array_like
values for the parameters. (default: self.parameters)
numDerivative( xdata, param ) |
---|
Parameters
- xdata : array_like
values at which to calculate the derivative - param : array_like
values for the parameters. (default: self.parameters)
Raises
ValueError when the number of xdata dimensions > 1.
Methods inherited from BaseModel |
---|
- checkParameter( param )
- checkPositive( param )
- checkZeroParameter( param )
- isDynamic( )
- isModifiable( )
- shortName( )
- setPrior( kpar, prior=None, **kwargs )
- hasPriors( isBound=True )
- getPrior( kpar )
- basePrior( kpar )
- getParameterName( kpar )
- baseParameterName( kpar )
- getParameterUnit( kpar )
- baseParameterUnit( kpar )
- hasLimits( fitindex=None )