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

knots = numpy.arange( 17, dtype=float ) * 10    # make equidistant knots from 0 to 160
csm = SplinesModel( knots=knots, order=2 )
print csm.getNumberOfParameters( )
18
# or alternatively
csm = SplinesModel( nrknots=17, order=2, min=0, max=160 )    # automatic layout of knots
print csm.getNumberOfParameters( )
18
# or alternatively
npt = 161                                               # to include both 0 and 160.
x = numpy.arange( npt, dtype=float )                    # x-values
csm = SplinesModel( nrknots=17, order=2, xrange=x )     # automatic layout of knots
print csm.getNumberOfParameters( )
18

Attributes

  • minKnots : int
         minimum number of knots
  • maxDegree : int or None
         maximum number of knots

Attributes from Modifiable

     modifiable

Attributes from Dynamic

     dynamic, ncomp (=degree+1), deltaNpar, minComp (=minDegree+1), maxComp (=maxDegree+1), growPrior

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, copy=None, **kwargs )

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

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

Parameters

  • modifiable : bool
         if True allow changement of the knot locations
  • dynamic : bool
         if True allow growth and shrinkage of number of knots
  • minKnots : int
         minimum number of knots (def=2)
  • maxKnots : None or int
         maximum number of Knots
  • minDistance : float
         minimum distance between knots, provided as fraction of average knot distance.
         default is ( 0.01 * ( knots[-1] - knots[0] ) / nrknots )
  • 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 )

baseName( )

Returns a string representation of the model.

changeNComp( dn )

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

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
         to generate a new parameter (obligatory)

Return

  • bool : succes

vary( rng=None, location=None )

varyAlt( offset=0, rng=None, **kwargs )
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