class CombiModel( BracketModel ) | Source |
---|
CombiModel combines a number of copies of the same model.
Fixed relations can be set between similar parameters. The relations can be either multiplicative or additive. When these relations are set, they must be set for all models.
f( x:p ) = ∑ g( x:p )
where g( x:p ) is a model ( e.g. GaussModel )
For consistency reasons it is not possible to change the attributes of a CombiModel. It is better to make a new one with the required settings.
As we have copies of the same model, each model can have its own priors.
Attributes
- nrepeat : int
number of Models in this CombiModel - nmp : int
number of parameters in each Model - expandpar : array of float
expanded parameters. to be used in the repeated models - npcmax : int
number of parameters in expandpar (= nmp * nrepeat) - expandindex : array of int
converts parameter index into expandpar index - addindex : array of int
indices of additively connected parameters - addvalue : array of float
list of values to be added to the parameters in addindex - mulindex : array of int
indices of multiplicatively connected parameters - mulvalue : array of float
list of values to be multiplied to the parameters in mulindex - select : array of int
indices of expandpar to get parameters
Attributes from BracketModel
model, deep
Attributes from Model
npchain, parameters, stdevs, xUnit, yUnit
Attributes from FixedModel
npmax, fixed, parlist, mlist
Attributes from BaseModel
npbase, ndim, priors, posIndex, nonZero, tiny, deltaP, parNames
Examples
gauss = GaussModel( )
combi = CombiModel( gauss, 3, addCombi={1:[0,0.1,0.3]}, mulCombi={2,[0]*3} )
print( combi )
Combi of 3 times GaussModel
print( combi.npchain, combi.nrepeat, combi.nmp, combi.nexpand )
5 3 3 9
print( combi.select )
[0 1 2 3 6]
print( combi.expandindex )
[0 1 2 3 1 2 4 1 2]
print( combi.modelindex )
[0 0 0 1 2]
print( combi.addindex )
[1 4 7]
print( combi.mulindex )
[2 5 8]
Category mathematics/Fitting
Notes
- When all parameters are left free, precise initial parameters are needed to converge to the global optimum.
- The model seems to be especially unstable when the basic models are overlapping. Fixing the widths relative to each other, helps.
- Using a PolynomialModel ( or similar ones ) as basic model, is not going to work.
CombiModel( model, nrepeat=1, copy=None, oper='add', addCombi=None, mulCombi=None, **kwargs ) |
---|
CombiModel combines several copies of the same model int one.
Parameters
- model : Model
model to be repeated - nrepeat : int
number of repetitions - oper : "add" or "mul"
the repeated models are combined using this operation - addCombi : None or dict
make additive connections between parameters
None : no additive connection
dict : { int : array }
key : int
index pointing to the key-th parameter in the model
value : array of nrepeat floats
values added to each of the key-th parameters - mulCombi : None or dict
make multiplicative connections between parameters
None : no multiplicative connection
dict : { int : array }
key : int
index pointing to the key-th parameter in the model
value : array of nrepeat floats
values multiplied to each of the key-th parameters
copy( ) |
---|
combine( addCombi=None, mulCombi=None ) |
---|
Parameters
- addCombi : None or dict
make additive connections between parameters
None : no additive connection
dict : { int : array }
key : int
index pointing to the key-th parameter in the model
value : array of nrepeat floats
values added to each of the key-th parameters - mulCombi : None or dict
make multiplicative connections between parameters
None : no multiplicative connection
dict : { int : array }
key : int
index pointing to the key-th parameter in the model
value : array of nrepeat floats
values multiplied to each of the key-th parameters
makeExpandIndex( expandindex, amindex ) |
---|
setCombi( combi ) |
---|
expandParameters( param ) |
---|
baseResult( xdata, params ) |
---|
Parameters
- xdata : array_like
values at which to calculate the result - params : array_like
values for the parameters.
basePartial( xdata, params, parlist=None ) |
---|
Parameters
- xdata : array_like
values at which to calculate the partials - params : array_like
values for the parameters. - parlist : array_like
Not in use
baseDerivative( xdata, params ) |
---|
Parameters
- xdata : array_like
values at which to calculate the partials - params : array_like
values for the parameters.
baseName( ) |
---|
Returns a string representation of the model.
baseParameterName( kpar ) |
---|
Parameters
- kpar : int
parameter number.
baseParameterUnit( k ) |
---|
Parameters
- k : int
parameter number.
getPrior( kpar ) |
---|
First try at the kpar location, possibly further in the chain; Upon failure try at the equivalent position in the head model
Parameters
- kpar : int
index of the parameter to be selected.
Methods inherited from BracketModel |
---|
Methods inherited from Brackets |
---|
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 )
- isDynamic( )
- getParameterName( kpar )
- getParameterUnit( kpar )
- getIntegralUnit( )
- setLimits( lowLimits=None, highLimits=None )
- getLimits( )
- hasLimits( fitindex=None )
- unit2Domain( uvalue, kpar=None )
- domain2Unit( dvalue, kpar=None )
- partialDomain2Unit( dvalue )
- 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 |
---|