BayesicFitting

Model Fitting and Evidence Calculation

View project on GitHub



class Kernel( object )Source

A kernel is an even real-valued integrable function.

It is satisfying the following two requirements

  1. The integral over [-Inf,+Inf] exists ( < Inf ).
  2. It is an even function: K( x ) = K( -x ).

A kernel is called bound when it is 0 everywhere except when |x| < range < inf.

All kernels are scaled such that its value at x=0 is 1.0.

Several kernel functions, K( x ) are defined in this package

Name Definition Integral FWHM range comment
Biweight ( 1-x2 )2 16/15 1.08 1.0 aka Tukey
CosSquare cos2(0.5*π*x) 1.0 1.00 1.0
Cosine cos( 0.5*π*x ) 4/π 1.33 1.0
Gauss exp( -0.5*x2 ) √(2*π) 1.22 inf
Huber min( 1, 1/|x| ) inf 4.00 inf improper
aka Median
Lorentz 1 / ( 1 + x2 ) π 2.00 inf
Parabola 1 - x2 4/3 1.41 1.0
Sinc sin(π*x)/(π*x) 1.0 1.21 inf
Triangle 1 - |x| 1.0 1.00 1.0
Tricube ( 1 - |x|3 )3 81/70 1.18 1.0
Triweight ( 1 - x2 )3 32/35 0.91 1.0
Uniform 1.0 2.0 2.00 1.0 aka Clip
Tophat 0 1.0 1.0 1.00 0.5 like Uniform
Tophat 1 1 - |x| 1.0 1.00 1.0 aka Triangle
Tophat 2 2nd order polynome 1.0 1.26 1.5
Tophat 3 3rd order polynome 1.0 1.44 2.0
Tophat 4 4th order polynome 1.0 1.60 2.5
Tophat 5 5th order polynome 1.0 1.73 3.0
Tophat 6 6th order polynome 1.0 1.86 3.5

For all bound Kernels the definition in the table is true for |x| < range; elsewhere it is 0.

Huber is not a proper Kernel as the integral is inf. However it is important in robust fitting (RobustShell) to get a madian-like solution for the outliers.

Attributes

  • integral : float
         the integral over the valid range
  • fwhm : float
         the full width at half maximum
  • range : float
         the region [-range..+range] where the kernel is non-zero.

Author Do Kester

Category mathematics/Fitting

Kernel( integral=1.0, fwhm=1.0, range=1.0 )

Constructor

Parameters

  • integral : float
         over [-inf, +inf]
  • fwhm : float
         full width at half maximum
  • range : float
         the region [-range,+range] where the kernel is nonzero

result( x )
Return the result for input values.

Parameters

  • x : array-like
         input values

resultsq( xsq )
Return the result for squared input values.

Parameters

  • x : array-like
         the squares of the input values

partial( x )
Return the partial derivative wrt the input values.

Parameters

  • x : array-like
         the input values

isBound( )
Return true when the kernel is bound, i.e. all non-zero values are between -1 and +1

name( )
Return the name of the kernel.