CombiModel = class CombiModel(BracketModel) |
|
CombiModel(model, nrepeat=1, copy=None, oper='add', addCombi=None,
mulCombi=None, **kwargs)
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.
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
-----
1. When all parameters are left free, precise initial parameters are
needed to converge to the global optimum.
2. The model seems to be especially unstable when the basic models
are overlapping. Fixing the widths relative to each other, helps.
3. Using a PolynomialModel ( or similar ones ) as basic model, is not going
to work. |
|
- Method resolution order:
- CombiModel
- BracketModel
- Model.Brackets
- Model
- FixedModel
- BaseModel
- builtins.object
Constructor:
- 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
Methods defined here:
- baseDerivative( xdata, params )
- Returns the derivative (df/dx) calculated at the xdatas.
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( 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 partial derivatives calculated at the xdatas.
Parameters
----------
xdata : array_like
values at which to calculate the partials
params : array_like
values for the parameters.
parlist : array_like
Not in use
- baseResult( xdata, params )
- Returns the result calculated at the xdatas.
Parameters
----------
xdata : array_like
values at which to calculate the result
params : array_like
values for the parameters.
- combine( addCombi=None, mulCombi=None )
- (re)sets the value of attributes "addindex", "addvalue", "mulindex", "mulvalue",
"select" and "expandindex".
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
- copy()
- Copy method.
- expandParameters( param )
- makeExpandIndex( expandindex, amindex )
- Make an expanded index enumerating the parameters for the full model
- setCombi( combi )
Methods inherited from Model.Brackets:
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()
- getLinearIndex()
- getNumberOfParameters()
- getParameterName( k )
- getParameterUnit( k )
- getPrior( k )
- hasLimits( fitindex=None )
- isDynamic()
- isMixed()
- isNullModel()
- isolateModel( k )
- multiplyModel( model )
- 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:
|
|