LogNormal.cxx

Go to the documentation of this file.
00001 
00012 #ifdef _MSC_VER
00013 #include "msdevstudio/MSconfig.h"
00014 #endif
00015 
00016 #include "LogNormal.h"
00017 
00018 #include "FunctionHelper.h"
00019 
00020 #include <cmath>
00021 #include <cassert>
00022 
00023 using std::distance;
00024 
00025 using std::exp;
00026 using std::vector;
00027 
00028 using namespace hippodraw;
00029 
00030 LogNormal::LogNormal ( )
00031 {
00032   initialize ();
00033 }
00034 
00035 LogNormal::LogNormal ( double n, double m, double s )
00036 {
00037   initialize ();
00038   
00039   m_parms[norm] = n;
00040   m_parms[mu] = m;
00041   m_parms[sigma] = s;
00042 }
00043 
00044 void LogNormal::initialize ()
00045 {
00046   m_name = "LogNormal";
00047 
00048   m_parm_names.push_back ( "Norm" );
00049   m_parm_names.push_back ( "Mu" );
00050   m_parm_names.push_back ( "Sigma" );
00051 
00052   resize ();
00053 }
00054 
00055 FunctionBase * LogNormal::clone () const
00056 {
00057   return new LogNormal ( *this );
00058 }
00059 
00060 double LogNormal::operator () ( double x ) const
00061 {
00062   double t = ( log ( x ) - m_parms[mu] ) / m_parms[sigma];
00063   double result = m_parms[norm] * exp ( -0.5 * t*t );
00064 
00065   return result;
00066 }
00067 
00070 void 
00071 LogNormal::
00072 initialParameters ( const FunctionHelper * helper )
00073 {
00074   m_parms[norm] = 1.0;
00075   m_parms[mu] =  log ( helper->meanCoord () );
00076   m_parms[sigma] = 0.5;
00077 }
00078 
00079 double
00080 LogNormal::
00081 derivByParm ( int , double ) const
00082 {
00083   assert ( false );
00084   return 0.;
00085 }
00086 
00087 bool
00088 LogNormal::
00089 hasDerivatives () const
00090 {
00091   return false;
00092 }

Generated for HippoDraw Class Library by doxygen