BayesicFitting

Model Fitting and Evidence Calculation

View project on GitHub



class Kernel2dModel( NonLinearModel )Source

Two dimensional Kernel Model.

The Kernel2dModel is defined as

  f( x:p ) = p0 * K( r )

where K( r ) is a selectable kernel function and r is the distance to the center.

  r = sqrt( u2 + v2 ).

There are 3 options for u and v

  1. CIRCULAR has 4 parameters

         Circular shape with only one width.
         u = ( x - p1 ) / p3
         v = ( x - p2 ) / p3
  2. ELLIPTIC has 5 parameters

         Elliptic shape aligned along the axes; 2 widths.
         u = ( x - p1 ) / p3
         v = ( x - p2 ) / p4
  3. ROTATED has 6 parameters

         Rotated elliptical shape with 2 width and a rotational angle.
         u = ( ( x - p1 )*cos( p5 ) - ( y - p2 )*sin( p5) ) / p3
         v = ( ( x - p1 )*sin( p5 ) + ( y - p2 )*cos( p5) ) / p4

The "center" parameters ( 1&2 ) and the "angle" parameter ( 5 ) are initilized as 0. The rotational angle is measured counterclockwise from the x-axis. The "width" parameters ( 3&4 ) are initialized as 1.0, except for the ROTATED case; then they need to be different ( 2.0 and 0.5 resp. ). Otherwise the model parameter "angle" is degenerate. The "amplitude" parameter is set to 1.0.

Several kernel functions, K( x ) are defined in the directory fit/kernels.

Beware: These models are unaware of anything outside their range.

Author: Do Kester

Example

model = Kernel2dModel( )                                 # default: circular Gauss
model.setKernelShape( Lorentz(), 'Elliptic'  )             # elliptic Lorentz model.
model = Kernel2dModel( shape=3 )                         # rotated Gauss
  • Category : mathematics/Fitting

Kernel2dModel( kernel=Gauss(), shape=1, copy=None, **kwargs )

Kernel Model.

Default model: Gauss with Circular shape.

Parameters

  • kernel : Kernel
         the kernel to be used
  • shape : 1 | 2 | 3 | 'circular' | 'elliptic' | 'rotated'
         int : resp.: circular elliptic, rotated
         str : case insensitive; only the first letter matters.
         shape defaults to 'circular' when misunderstood
  • copy : Kernel2dModel
         to be copied
  • fixed : None or dictionary of {int:float|Model}
         int index of parameter to fix permanently.
         float|Model values for the fixed parameters.
         Attribute fixed can only be set in the constructor.
         See: FixedModel

copy( )

Copy method.

parseShape( shape )

setKernelShape( kernel, shape )

baseName( )

Returns a string representation of the model.

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

baseDerivative( xdata, params )
Returns df/dx 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 partials at the xdata value.

Parameters

  • xdata : array_like
         value at which to calculate the partials
  • params : array_like
         parameters to the model (ignored in LinearModels)
  • parlist : array_like
         list of indices of active parameters

baseParameterUnit( k )
Return the unit of a parameter. Parameters
  • k : int
         the kth parameter.

isBound( )
Methods inherited from NonLinearModel
Methods inherited from Model
Methods inherited from FixedModel
Methods inherited from BaseModel