class RepeatingModel( Model,Dynamic ) | Source |
---|
RepeatingModel is a dynamic model, that calls the same model zero or more times, each time with the next set of parameters.
RepeatingModel is a Dynamic model that grows and shrinks according to a growPrior. The growPrior defaults to ExponentialPrior, unless a maxComp (max nr of components) then it defaults to a UniformPrior with limits minComp .. maxComp.
When isDynamic is set to False or minComp == maxComp, the RepeatingModel is a normal model with a static number of parameters/components.
Priors and/or limits for the RepeatingModel are stored in the (encapsulated) model. So the priors are taken from the same set for subsequent repetitions of the model call.
It can be arranged that all similar parameters are the same, represented by the same parameters. Use keywords same=.
Attributes
- ncomp : int
number of repetitions - model : Model
(encapsulated) model to be repeated - same : None or int or list of int
indices of parameters of model that get identical values - index : list of int
list of parameter indices not in same. - isDyna : bool
Whether this is a Dynamic Model.
Attributes from Dynamic
ncomp, deltaNpar, minComp, maxComp, growPrior
Attributes from Model
parameters, stdevs, npchain, _next, _head, _operation, xUnit, yUnit
Attributes from FixedModel
npmax, fixed, parlist, mlist
Attributes from BaseModel
npbase, ndim, priors, posIndex, nonZero, tiny, deltaP, parNames
Example
# Define a model containing between 1 and 6 VoigtModels, starting with 3
# and all with the same widths (for Gauss and Cauchy)
vgt = VoigtModel()
mdl = RepeatingModel( 3, vgt, minComp=1. maxComp=6, same=[2,3] )
print( mdl.npbase ) # 4 + 2 + 2
8
# Define a static RepeatingModel of 5 GaussModels
gm = GaussModel()
mdl = RepeatingModel( 5, gm, isDynamic=False )
print( mdl.npbase ) # 5 * 3
15
# Define a RepeatingModel with and exponential grow prior with scale 10
mdl = RepeatingModel( 1, gm, growPrior=ExponentialPrior( scale=10 ) )
print( mdl.npbase ) # 3
3
Author Do Kester
RepeatingModel( ncomp, model, minComp=0, maxComp=None, fixed=None, same=None, growPrior=None, dynamic=True, copy=None, **kwargs ) |
---|
Repeating the same model several times.
Parameters
-
ncomp : int
number of repetitions -
model : Model
model to be repeated -
minComp : int (0)
minimum number of repetitions -
maxComp : None or int
maximum number of repetitions -
same : None or int or list of int
indices of parameters of model that get identical values -
growPrior : None or Prior
governing the birth and death.
ExponentialPrior (scale=2) if maxOrder is None else UniformPrior -
dynamic : bool (True)
Whether this is a Dynamic Model. -
copy : RepeatingModel
model to copy
Raises
AttributeError when fixed parameters are requested ValueError when order is outside [min..max] range
copy( ) |
---|
changeNComp( dn ) |
---|
setSame( same ) |
---|
Parameters
- same : None or int or [int]
similar parameters indicated as an index in encapsulated model.
grow( offset=0, rng=None, **kwargs ) |
---|
Parameters
- offset : int
index where the dynamic model starts - rng : RandomState
random numbr generator
Return
- bool : succes
shrink( offset=0, **kwargs ) |
---|
Parameters
- offset : int
index where the dynamic model starts
Return
- bool : succes
shuffle( param, offset, np, rng ) |
---|
Parameters
- param : array-like
list of all parameters - offset : int
index where the dynamic model starts - np : int
length of the parameters of the dynamic model - rng : RNG
random number generator
isDynamic( ) |
---|
baseResult( xdata, params ) |
---|
Parameters
- xdata : array_like
value at which to calculate the result - params : array_like
values for the parameters
basePartial( xdata, params, parlist=None ) |
---|
Parameters
- xdata : array_like
value at which to calculate the result - params : array_like
values for the parameters - parlist : array_like
list of indices of active parameter
baseDerivative( xdata, params ) |
---|
Parameters
- xdata : array_like
value at which to calculate the result - params : array_like
values for the parameters
xxxsetLimits( lowLimits=None, highLimits=None ) |
---|
setPrior( kpar, prior=None, **kwargs ) |
---|
All repeated parameters have the same Prior.
Parameters
- kpar : int
parameter number of the repeated model. - prior : Prior
prior for parameter kpar - kwargs : keyword arguments
attributes to be passed to the prior
Raise:
IndexException
When more Priors are set than fit inside the repeated model
hasPriors( ) |
---|
basePrior( kpar ) |
---|
Parameters
- kpar : int
index of the parameter to be selected.
baseName( ) |
---|
Return a string representation of the model.
baseParameterName( k ) |
---|
Parameters
- k : int
parameter number.
baseParameterUnit( k ) |
---|
Parameters
- k : int
parameter number.
par2model( k ) |
---|
Methods inherited from Model, |
---|
- chainLength( )
- isNullModel( )
- isolateModel( k )
- addModel( model )
- subtractModel( model )
- multiplyModel( model )
- divideModel( model )
- pipeModel( model )
- appendModel( model, operation )
- correctParameters( params )
- result( xdata, param=None )
- operate( res, pars, next )
- derivative( xdata, param, useNum=False )
- partial( xdata, param, useNum=False )
- selectPipe( ndim, ninter, ndout )
- pipe_0( dGd, dHdG )
- pipe_1( dGd, dHdG )
- pipe_2( dGd, dHdG )
- pipe_3( dGd, dHdG )
- pipe_4( dGdx, dHdG )
- pipe_5( dGdx, dHdG )
- pipe_6( dGdx, dHdG )
- pipe_7( dGdx, dHdG )
- pipe_8( dGdx, dHdG )
- pipe_9( dGdx, dHdG )
- shortName( )
- getNumberOfParameters( )
- numDerivative( xdata, param )
- numPartial( xdata, param )
- getPrior( kpar )
- getParameterName( kpar )
- getParameterUnit( kpar )
- getIntegralUnit( )
- setLimits( lowLimits=None, highLimits=None )
- getLimits( )
- hasLimits( fitindex=None )
- unit2Domain( uvalue, kpar=None )
- domain2Unit( dvalue, kpar=None )
- partialDomain2Unit( dvalue )
- nextPrior( )
- isMixed( )
- getLinearIndex( )
- testPartial( xdata, params, silent=True )
- strictNumericPartial( xdata, params, parlist=None )
- assignDF1( partial, i, dpi )
- assignDF2( partial, i, dpi )
- strictNumericDerivative( xdata, param )
Methods inherited from FixedModel |
---|
Methods inherited from BaseModel |
---|
Methods inherited from Dynamic |
---|