LogNormal.cxx
Go to the documentation of this file.
1 
12 #ifdef _MSC_VER
13 #include "msdevstudio/MSconfig.h"
14 #endif
15 
16 #include "LogNormal.h"
17 
18 #include "FunctionHelper.h"
19 
20 #include <cmath>
21 #include <cassert>
22 
23 using std::distance;
24 
25 using std::exp;
26 using std::vector;
27 
28 using namespace hippodraw;
29 
31 {
32  initialize ();
33 }
34 
35 LogNormal::LogNormal ( double n, double m, double s )
36 {
37  initialize ();
38 
39  m_parms[norm] = n;
40  m_parms[mu] = m;
41  m_parms[sigma] = s;
42 }
43 
45 {
46  m_name = "LogNormal";
47 
48  m_parm_names.push_back ( "Norm" );
49  m_parm_names.push_back ( "Mu" );
50  m_parm_names.push_back ( "Sigma" );
51 
52  resize ();
53 }
54 
56 {
57  return new LogNormal ( *this );
58 }
59 
60 double LogNormal::operator () ( double x ) const
61 {
62  double t = ( log ( x ) - m_parms[mu] ) / m_parms[sigma];
63  double result = m_parms[norm] * exp ( -0.5 * t*t );
64 
65  return result;
66 }
67 
70 void
73 {
74  m_parms[norm] = 1.0;
75  m_parms[mu] = log ( helper->meanCoord () );
76  m_parms[sigma] = 0.5;
77 }
78 
79 double
81 derivByParm ( int , double ) const
82 {
83  assert ( false );
84  return 0.;
85 }
86 
87 bool
90 {
91  return false;
92 }
virtual FunctionBase * clone() const
Creates a new function object by copying an existing one.
Definition: LogNormal.cxx:55
hippodraw::LogNormal class interface
FunctionHelper class interface.
std::vector< double > m_parms
The parameter values.
Definition: FunctionBase.h:109
virtual void initialize()
Initializes the function and parameter names.
Definition: LogNormal.cxx:44
LogNormal()
The default constructor.
Definition: LogNormal.cxx:30
virtual bool hasDerivatives() const
Returns false as this function has not implemented calculation of partial derivatives.
Definition: LogNormal.cxx:89
A function that can be added to a DataRep and used in a fitter.
Definition: FunctionBase.h:90
virtual double operator()(double x) const
The function call operator.
Definition: LogNormal.cxx:60
An abstract base class to help FunctionBase objects perform some operations.
virtual double derivByParm(int i, double x) const
Returns the function&#39;s derivative at the coordinate value x with respect to the i-th parameter...
Definition: LogNormal.cxx:81
std::string m_name
The name of the function.
Definition: FunctionBase.h:103
std::vector< std::string > m_parm_names
The names of the function parameters.
Definition: FunctionBase.h:106
virtual void resize()
Re-sizes the appropriate vectors maintained in this base class.
virtual double meanCoord() const =0
Returns the mean of the coordinates along a X axis in the data set.
virtual void initialParameters(const FunctionHelper *helper)
Definition: LogNormal.cxx:72

Generated for HippoDraw Class Library by doxygen