13 #include "msdevstudio/MSconfig.h"
25 #ifdef ITERATOR_MEMBER_DEFECT
32 using namespace hippodraw;
34 Gaussian::Gaussian ( )
39 Gaussian::Gaussian (
double n,
double m,
double s )
48 void Gaussian::initialize ()
52 m_parm_names.push_back (
"Norm" );
53 m_parm_names.push_back (
"Mean" );
54 m_parm_names.push_back (
"Sigma" );
64 double Gaussian::operator () (
double x )
const
67 if ( m_parms[sigma] != 0.0 ) {
68 double t = ( x - m_parms[mean] ) / m_parms[sigma];
70 if ( fabs ( t ) < 50.0 ) {
71 value = exp ( -t ) / ( 2.50662828 * m_parms[sigma] );
75 if ( x == m_parms[mean] ) value = 1.0;
77 return value * m_parms[
norm];
90 m_parms[
norm] = total * ( max_x - min_x ) / size;
92 m_parms[sigma] = helper->
stdCoord ();
95 double Gaussian::derivByParm (
int i,
double x )
const
99 return derivByNorm ( x );
103 return derivByMean ( x );
107 return derivBySigma ( x );
117 double Gaussian::derivByNorm (
double x )
const
119 if ( m_parms[sigma] != 0.0 ) {
120 double t = ( x - m_parms[mean] ) / m_parms[sigma];
122 if ( fabs ( t ) > 50.0 ) {
126 return exp ( -t ) / ( 2.50662828 * m_parms[sigma] );
130 if ( x != m_parms[mean] ) {
138 double Gaussian::derivByMean (
double x )
const
140 double dx = x - m_parms[mean];
141 if ( m_parms[sigma] != 0.0 ) {
142 return m_parms[
norm] * dx
143 * exp ( -dx*dx / ( 2.0 * m_parms[sigma] * m_parms[sigma] ) )
144 / ( 2.50662828 * m_parms[sigma] * m_parms[sigma] * m_parms[sigma] );
147 if ( x != m_parms[mean] )
return 0.0;
152 double Gaussian::derivBySigma (
double x )
const
154 if ( m_parms[sigma] == 0.0 )
return 0.0;
155 double dx = x - m_parms[mean];
156 double p2 = m_parms[sigma] * m_parms[sigma];
157 double ex = exp ( -dx*dx / ( 2.0 * p2 ) );
158 return m_parms[
norm] * ( dx*dx * ex / ( p2*
p2) - ex / p2 ) / 2.50662828;
Gaussian class interface.
A function that can be used with a fitter.
FunctionHelper class interface.
virtual double minCoord() const =0
Returns the smallest coordinate value along the X axis in the data set.
numeric::array clone(numeric::array arr)
intp size(numeric::array arr)
A function that can be added to a DataRep and used in a fitter.
double norm(const std::vector< double > &a)
Computes the two norm of the vector.
An abstract base class to help FunctionBase objects perform some operations.
virtual double stdCoord() const =0
Returns the standard deviation of the coordinates along a X axis in the data set. ...
virtual double maxCoord() const =0
Returns the largest coordinate value along the X axis in the data set.
virtual double getTotal() const =0
Returns the sum of the values of the data set.
virtual double meanCoord() const =0
Returns the mean of the coordinates along a X axis in the data set.
virtual int size() const =0
Returns the number of points in the data set.