BayesicFitting

Model Fitting and Evidence Calculation

View project on GitHub



class Dynamic( object )Source

Class adjoint to Model which implements some dynamic behaviour.

Attributes

  • ncomp : int
         the number of components in the dynamic model
  • deltaNpar : int
         the number of parameters in each component
  • minComp : int
         minimum number of repetitions
  • maxComp : None or int
         maximum number of repetitions
  • growPrior : None or Prior
         governing the birth and death.
         ExponentialPrior (scale=2) if maxOrder is None else UniformPrior

Dynamic( dynamic=True )

Constructor for Dynamic

Parameters

  • dynamic : bool
         True if the Model is to be considered dynamic.

isDynamic( )

setGrowPrior( growPrior=None, min=1, max=None, name="Comp" )
Set the growth prior.

Parameters

  • growPrior : None or Prior
         governing the birth and death.
         ExponentialPrior (scale=2) if maxOrder is None else UniformPrior
  • min : int
         lower limit on growthprior
  • max : None or int
         upper limit on growthprior
  • name : str
         name of the component

setDynamicAttribute( name, value )
Set attribute, if it belongs to a Dynamic Models.

Parameters

  • name : str
         name of the attribute
  • value : anything
         value of the attribute

Return

  • bool : True if name was a Dynamic name
            False if not

grow( offset=0, rng=None, **kwargs )
Increase the degree by one upto maxComp ( if present ).

Parameters

  • offset : int
         index where the params of the Dynamic model start
  • rng : random number generator
         to generate a new parameter.

Return

  • bool : succes

shrink( offset=0, rng=None, **kwargs )
Decrease the degree by one downto minComp ( default 1 ).

Parameters

  • offset : int
         index where the params of the Dynamic model start
  • rng : random number generator
         Not used in this implementation

Return

  • bool : succes

alterParameterNames( dnp )
Renumber the parameter names.

Parameters

  • dnp : int
         change in the number of parameters

alterParameterSize( dnp, offset, location=None, value=0 )
Change the number of parameters and self.parameters.

Parameters

  • dnp : int
         change in the number of parameters in the DynamicModel
  • offset : int
         starting index of the DynamicModel
  • location : int
         index in param[offset:] at which to insert/delete the new parameters

alterParameters( param, location, dnp, offset, value=None )
change the parameters to comply with the changed model.

param: [p0 p1 p2 p3 p4 p5 p6 p7 p8 p9] # previous set offset: 2 # parameters of models in preceeding chain location: 1 # location where to add/delete parameter value: [v0 ...] # values to be given to added parameters

dnp: +1 ==> newpar: [p0 p1 p2 v0 p3 p4 p5 p6 p7 p8 p9]

dnp: +2 ==> newpar: [p0 p1 p2 v0 v1 p3 p4 p5 p6 p7 p8 p9]

dnp: -1 ==> newpar: [p0 p1 p3 p4 p5 p6 p7 p8 p9]

dnp: -2 ==> ERROR: not enough space in param before location

Parameters

  • param : array_like
         parameters of the parent model (chain)
  • location : int
         index in param[offset:] at which to insert/delete the new parameters
  • dnp : int
         number of parameters to insert (dnp>0) or delete (dnp<0)
  • offset : int
         start index of the parameters of the dynamic model in param
  • value : float or array_like
         to be given to the inserted parameters (only when dnp>0)

alterFitindex( findex, location, dnp, offset )
change the fit index to comply with the changed model.

Parameters

  • findex : array_like
         fit index of the parent model (chain)
  • location : int
         index in param[offset:] at which to insert/delete the new parameters
  • dnp : int
         number of parameters to insert (dnp>0) or delete (dnp<0)
  • offset : int
         start index of the parameters of the dynamic model in param

shuffle( param, offset, np, rng )
Shuffle the parameters of the components (if they are equivalent) Default implementation: does nothing.

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