BayesicFitting

Model Fitting and Evidence Calculation

View project on GitHub



class FreeShapeModel( LinearModel )Source

Pixelated Model.

f( x:p ) = p( expanded )

where p is a array of amplitudes of the same size as the input x divided by the number of pixels per bin ( ppb ). When ppb > 1, each p has a shape which is used to fill the pixels of the bin. Initially the shape is a top-hat, which can be autoconvolved.

By default ppb = 5.

The parameters are initialized at 0.

Although this is a LinearModel it will not work very well with the ( linear ) Fitter. It will be a very ill-posed problem.

Using NestedSampler its exponential prior will ensure that all parameters are kept positive.

Attributes

  • npix : int
         Number of pixels in result. Is also npar.
  • xlo : float ( default 0 )
         Lowest value in xdata
  • xhi : float ( default npix )
         Highest value in xdata
         xlo and xhi define the valid domain of the model.
         All input data must be: xlo <= xdata <= xhi
  • shape : Kernel
         shape of convolving function
  • center : float (between 0..1)
         position of the center of shape with respect to the pixels

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

nn = 100
fsm = FreeShapeModel( nn, nconvolve=4, xlo=-1.0, xhi=4.0 )
print( fsm.shape )

Author Do Kester

FreeShapeModel( npix, copy=None, shape=None, nconvolve=0, center=0.5, xlo=0.0, xhi=None, **kwargs )

Free Shape model with npix pixels.

The number of parameters equals the number of pixels

Parameters

  • npix : int
         number of pixels = npar
  • copy : FreeShapeModel
         model to be copied
  • shape : None or Kernel
         None : Use Tophat(), convolved nconvolve times.
         Kernel : use the kernel as shape; nconvolve does not apply.
  • nconvolve : int
         number of (auto)convolutions on Tophat
  • center : float (between 0..1)
         positions where the pixels are centered.
         default: 0.5 -> pixels run from k to k+1
  • xlo : float ( default 0.0 )
         lowest value in xdata
  • xhi : float ( default np )
         highest value in xdata

copy( )

Copy method.

checkDomain( xdata )
Check for all data inside domain defined by (xlo - range, xhi + range). range = self.shape.range

Parameters

  • xdata : array_like
         value at which to calculate the result

Raises

ValueError when outside domain.

baseResult( xdata, params )
Returns the result of the model function.

Parameters

  • xdata : array_like
         value at which to calculate the result
  • params : array_like
         values for the parameters

basePartial( xdata, params, parlist=None )
Returns the partial derivative of the model function to each of the parameters.

Parameters

  • xdata : array_like
         value at which to calculate the result
  • params : array_like
          values for the parameters

TBCbaseDerivative( xdata, params )
Returns the derivative of the model function df/dx.

Parameters

  • xdata : array_like
         value at which to calculate the result
  • params : array_like
          values for the parameters

baseName( )

baseParameterUnit( k )
Return the unit of the indicated parameter.

Parameters

  • k : int
         parameter number.
Methods inherited from LinearModel
Methods inherited from Model
Methods inherited from FixedModel
Methods inherited from BaseModel