BayesicFitting

Model Fitting and Evidence Calculation

View project on GitHub



class SplinesDynamicModel( Modifiable,Dynamic,BasicSplinesModel )[source]

BasicSplinesModel that is modifiable (knot locations) and dynamic (in number of knots)

Examples

# make dynamic splinesmodel, initially with 4 equidistant knots from 0 to 10
knots = numpy.linspace( 0, 10, 4, dtype=float )
csm = SplinesDynamicModel( knots=knots, modifiable=False )
print csm.getNumberOfParameters( )
6
# or similarly, also modifiable
csm = SplinesDynamicModel( nrknots=4, min=0, max=10 )
print csm.getNumberOfParameters( )
6
# or periodic and not dynamic
x = numpy.arange( npt, dtype=float )
knots = numpy.linspace( 0, 10, 4, dtype=float )
csm = SplinesDynamicModel( knots=knots, border=1, dynamic=False )
print csm.getNumberOfParameters( )
5

Attributes

  • minKnots : int
         minimum number of knots
  • maxKnots : int or None
         maximum number of knots
  • minDistance : float
         minimum distance between knots
  • border : int (0)
         0,1,2 as in BasicSplinesModel
         3 periodic (as 1) with flexible period
  • flexPeriod : bool
         flexible period when the model is periodic

Attributes from Modifiable
     modifiable

Attributes from Dynamic
     dynamic, ncomp, deltaNpar, minComp, maxComp, growPrior

Attributes from BasicSplinesModel
     border, period

Attributes from SplinesModel
     knots, order

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

Limitations
Dont construct the knots so closely spaced, that there are no datapoints in between.

SplinesDynamicModel( modifiable=True, dynamic=True, growPrior=None, minKnots=2, maxKnots=None, minDistance=0.01, border=0, copy=None, **kwargs ) [source]

Splines on a given set of knots and a given order.

The number of parameters is ( length( knots ) + order - 1 )

Parameters

  • modifiable : bool (True)
         if True allow changement of the knot locations
  • dynamic : bool (True)
         if True allow growth and shrinkage of number of knots
  • minKnots : int (2)
         minimum number of knots
  • maxKnots : None or int
         maximum number of Knots
  • minDistance : float ( 0.01 * mean knot separation )
         minimum distance between knots, provided as fraction of average knot distance.
  • border : int (0)
         0,1,2 as in BasicSplinesModel
         3 periodic (as 1) with flexible period
  • growPrior : None or Prior
         governing the birth and death.
         ExponentialPrior (scale=2) if maxDegree is None else UniformPrior
  • copy : PolynomialDynamicModel
         model to copy

Parameters for SplinesModel
knots, order, nrknots, min, max, xrange

Raises
ValueError if not minKnots <= nrknots <= maxKnots

copy( modifiable=None, dynamic=None ) [source]
Make a copy of the model, optionally unchangeable.

Parameters

  • modifiable : bool
         is a modifiable model
  • dynamic : bool
         is a dynamic model

baseName( ) [source]

Returns a string representation of the model.

changeNComp( dn ) [source]

grow( offset=0, rng=None, force=False, **kwargs ) [source]
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 (obligatory)
         to generate a new parameter.
  • force : bool
         dont check maxKnots (only for varyAlt())

Return

  • bool : succes

shrink( offset=0, rng=None, **kwargs ) [source]
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
         to generate a new parameter (obligatory)

Return

  • bool : succes

vary( rng=None, location=None ) [source]
Vary the structure of a Modifiable Model

Parameters

  • rng : RNG
         random number generator
  • location : int
         index of the item to be modified; otherwise random
  • kwargs : keyword arguments
         for specific implementations

varyAlt( offset=0, rng=None, **kwargs ) [source]
Vary the structure of a Modifiable Model

Parameters

  • offset : int
         index where the params of the Modifiable model start
  • rng : RNG
         random number generator
  • kwargs : keyword arguments
         for specific implementations
Methods inherited from Modifiable,
Methods inherited from Dynamic,
Methods inherited from BasicSplinesModel
Methods inherited from SplinesModel
Methods inherited from LinearModel
Methods inherited from Model
Methods inherited from FixedModel
Methods inherited from BaseModel