RepeatingModel = class RepeatingModel(Model, Dynamic) |
|
RepeatingModel(ncomp, model, minComp=0, maxComp=None, fixed=None,
same=None, growPrior=None, dynamic=True, copy=None, **kwargs)
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.
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 (relegated to model)
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 |
|
- Method resolution order:
- RepeatingModel
- Model
- FixedModel
- BaseModel
- Dynamic
- builtins.object
Constructor:
- 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
Methods defined here:
- baseDerivative( xdata, params )
- Returns the derivative df/dx at the input value.
Parameters
----------
xdata : array_like
value at which to calculate the result
params : array_like
values for the parameters
- baseName()
- Return a string representation of the model.
- baseParameterName( k )
- Return the name of the indicated parameter.
Parameters
----------
k : int
parameter number.
- baseParameterUnit( k )
- Return the unit of the indicated parameter.
Parameters
----------
k : int
parameter number.
- basePartial( xdata, params, parlist=None )
- Returns the partials at the input value.
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
- basePrior( k )
- Return the prior for parameter k.
Parameters
----------
k : int
the parameter to be selected.
- baseResult( xdata, params )
- Returns the result of the model function.
Parameters
----------
xdata : array_like
value at which to calculate the result
params : array_like
values for the parameters
- changeNComp( dn )
- copy()
- Copy method.
- grow( offset=0, rng=None, **kwargs )
- Increase the the number of components by 1 (if allowed by maxComp)
Parameters
----------
offset : int
index where the dynamic model starts
rng : RandomState
random numbr generator
Return
------
bool : succes
- hasPriors()
- Return True when the model has priors for all its parameters.
Parameters
----------
isBound : bool
Also check if the prior is bound.
- isDynamic()
- Return whether the model can change the number of parameters dynamically.
- par2model( k )
- Return index in model and repetition nr for param k
- setLimits( lowLimits=None, highLimits=None )
- Sets the limits for the parameters of the compound model.
1. It is valid to insert for either parameter a None value
indicating no lower/upper limits.
2. When a lowerlimit >= upperlimit no limits are enforced.
It only works in *Fitter classes which support it.
Parameters
----------
lowLimits : array_like
lower limits on the parameters
highLimits : array_like
upper limits on the parameters
- setSame( same )
- Assign similar parameters the same value.
Parameters
----------
same : None or int or [int]
similar parameters indicated as an index in encapsulated model.
- shrink( offset=0, **kwargs )
- Decrease the the number of componenets by 1 (if allowed by minComp)
Remove an arbitrary item.
Parameters
----------
offset : int
index where the dynamic model starts
Return
------
bool : succes
- shuffle( param, offset, np, rng )
- Shuffle the parameters of the components (if they are equivalent)
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
Methods inherited from Model:
Overloaded operators and aliases
Other methods
- addModel( model )
- appendModel( model, operation )
- assignDF1( partial, i, dpi )
- assignDF2( partial, i, dpi )
- chainLength()
- correctParameters( params )
- derivative( xdata, param, useNum=False )
- divideModel( model )
- domain2Unit( dvalue, kpar=None )
- getIntegralUnit()
- getLimits()
- getLinearIndex()
- getNumberOfParameters()
- getParameterName( k )
- getParameterUnit( k )
- getPrior( k )
- hasLimits( fitindex=None )
- isMixed()
- isNullModel()
- isolateModel( k )
- multiplyModel( model )
- nextPrior()
- numDerivative( xdata, param )
- numPartial( xdata, param )
- operate( res, pars, next )
- partial( xdata, param, useNum=False )
- partialDomain2Unit( dvalue )
- pipeModel( model )
- 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)
- result( xdata, param=None )
- selectPipe( ndim, ninter, ndout )
- setPrior( k, prior=None, **kwargs )
- shortName()
- strictNumericDerivative( xdata, param )
- strictNumericPartial( xdata, params, parlist=None )
- subtractModel( model )
- testPartial( xdata, params, silent=True )
- unit2Domain( uvalue, kpar=None )
Methods inherited from FixedModel:
Methods inherited from BaseModel:
Methods inherited from Dynamic:
- alterFitindex( findex, location, dnp, offset )
- alterParameterNames( dnp )
- alterParameterSize( dnp, offset, location=None, value=0)
- alterParameters( param, location, dnp, offset, value=None )
- setDynamicAttribute( name, value )
- setGrowPrior( growPrior=None, min=1, max=None, name='Comp')
|
|