Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | Private Member Functions
Landau Class Reference

The function represents the Landau distribution. More...

#include <Landau.h>

Inheritance diagram for Landau:
Inheritance graph
[legend]
Collaboration diagram for Landau:
Collaboration graph
[legend]

List of all members.

Public Member Functions

virtual void addToComposite (FunctionBase *)
 Does nothing.
virtual FunctionBaseclone () const
 Creates a new function object by copying an existing one.
virtual int count ()
 Returns 0.
virtual double derivByParm (int i, double x) const
 Returns the function's derivative at the coordinate value x with respect to the i-th parameter.
virtual unsigned int dimensions () const
 Returns the number of dimensions of the data coordinate.
virtual const std::vector
< double > & 
getParameters () const
 Returns the values of the parameters as a vector.
virtual bool hasDerivatives () const
 Returns false since the derivatives have not been implemented.
virtual void initialParameters (const FunctionHelper *helper)
 Sets the FunctionHelper so that the function can calculate a reasonable set of initial parameter values.
virtual double integrate (double lower_limit, double upper_limit) const
 Returns the integral of the function from the lower limit to the higher limit.
virtual bool isComposite () const
 Returns false.
 Landau ()
 The default constructor.
 Landau (double peak, double counts, double sigma)
 This constructor takes the values of the parameters as an argument.
const std::string & name () const
 Returns the name of the function.
virtual double operator() (double x) const
 The function call operator.
virtual double operator() (const std::vector< double > &v) const
 The function call operator for multi-dimension coordinate variable.
virtual const std::vector
< std::string > & 
parmNames () const
 Returns a reference to a vector of parameter names.
virtual void removeFromComposite (FunctionBase *)
 Does nothing.
virtual void setParameters (const std::vector< double > &incr)
 Sets the parameter values.
virtual std::vector< double >
::const_iterator 
setParameters (std::vector< double >::const_iterator it)
 Sets the parameter values to the value pointed to by the iterator.
void setParmNames (const std::vector< std::string > &names)
 Sets the names of the parameters.
virtual int size () const
 Returns the number of parameters.

Protected Member Functions

virtual void initialize ()
 Initializes the function and parameter names.
virtual void resize ()
 Re-sizes the appropriate vectors maintained in this base class.
void setName (const char *)
 Sets the name of the function.

Protected Attributes

std::string m_name
 The name of the function.
std::vector< std::string > m_parm_names
 The names of the function parameters.
std::vector< double > m_parms
 The parameter values.

Private Types

enum  { peak, norm, sigma }
 Indices to the parameter vectors. More...

Private Member Functions

double calcY (double x) const
 compute the reduced variable: $Y = \frac{x - mode}{sigma}$
double calcZ (double x) const
 Compute the helper variable for derivation: $Z = -0.5\times ( 1.0 - \exp{-y} ) $.
double derivByNorm (double x) const
 Calculates the derivative with respect to the counts parameter.
double derivByPeak (double x) const
 Calculates the derivative with respect to the peak parameter.
double derivBySigma (double x) const
 Calculates the derivative with respect to the sigma parameter.

Detailed Description

The function represents the Landau distribution.

This class represents a Landau distribution, as approximated by the Moyal formula

\[ Moyal(\lambda) = \frac{\exp{-0.5(\lambda+\exp{-\lambda})}}{\sqrt{2\pi}} \]

See J.E. Moyal, Theory of ionization fluctuations, Phil. Mag. 46 (1955) 263.

Note that this analytical approximation is too low in the tail.

In order to allow for a fit, we define

\[ \lambda = \frac{x - m}{s} \]

with x the dataset variable. $m$ and $s$ are fit parameters PAR(1) and PAR(2) respectively, and correspond to the mode and the width of the distribution. PAR(3) is a normalization factor, so that the concrete implemented formula is: $ Landau(\lambda(x)) = PAR(3) * Moyal(\lambda(x)) $.

Author:
From Goddard GLAST ACD team (Fortran version)
Paul F. Kunz Paul_.nosp@m.Kunz.nosp@m.@slac.nosp@m..sta.nosp@m.nford.nosp@m..edu (C++ conversion)
Johann Cohen-Tanugi johan.nosp@m.n.co.nosp@m.hen@p.nosp@m.i.in.nosp@m.fn.it (fixed normalization)

Definition at line 47 of file Landau.h.


Member Enumeration Documentation

anonymous enum [private]

Indices to the parameter vectors.

Enumerator:
peak 

Index to the peak parameter.

norm 

Index to the normalization parameter.

sigma 

Index to the sigma parameter.

Definition at line 52 of file Landau.h.


Constructor & Destructor Documentation

Landau ( )

The default constructor.

Definition at line 57 of file Landau.cxx.

Landau ( double  peak,
double  counts,
double  sigma 
)

This constructor takes the values of the parameters as an argument.

Definition at line 62 of file Landau.cxx.

References hippodraw::Numeric::norm().


Member Function Documentation

void addToComposite ( FunctionBase ) [virtual, inherited]

Does nothing.

Derived classes that are a composite of functions should override this member function and add functions to the composite.

Reimplemented in LinearSumFunction.

Definition at line 166 of file FunctionBase.cxx.

double calcY ( double  x) const [inline, private]

compute the reduced variable: $Y = \frac{x - mode}{sigma}$

Definition at line 87 of file Landau.h.

double calcZ ( double  x) const [inline, private]

Compute the helper variable for derivation: $Z = -0.5\times ( 1.0 - \exp{-y} ) $.

Definition at line 95 of file Landau.h.

FunctionBase * clone ( ) const [virtual]

Creates a new function object by copying an existing one.

The implementation raises an assertion as this member function should be reimplemented in s derived class.

Note:
There's an implementation here to satisfy the SIP interface.

Reimplemented from FunctionBase.

Definition at line 82 of file Landau.cxx.

int count ( ) [virtual, inherited]

Returns 0.

Derived classes that are a composite of functions should override this member function to return the number of functions in the composite.

Reimplemented in LinearSumFunction.

Definition at line 174 of file FunctionBase.cxx.

double derivByNorm ( double  x) const [private]

Calculates the derivative with respect to the counts parameter.

Definition at line 182 of file Landau.cxx.

References hippodraw::Numeric::norm().

double derivByParm ( int  i,
double  x 
) const [virtual, inherited]

Returns the function's derivative at the coordinate value x with respect to the i-th parameter.

Derived classes must implement this function.

Todo:
Provide a numeric method for doing this calculation that will be the default. Derived classes should provide more efficient analytic method if available.
Bug:
Make this function pure when problem compiling python/FunctionWrap under Windows is solved.

Reimplemented in LinearSumFunction, Erfc, FunctionWrap, Gaussian, ConstantF, Quadratic, BrokenPowerLaw, Chi2Dist, Quadratic2, Exponential, Linear, PowerLaw, LogNormal, Novosibirsk, and LogParabola.

Definition at line 190 of file FunctionBase.cxx.

double derivByPeak ( double  x) const [private]

Calculates the derivative with respect to the peak parameter.

Definition at line 189 of file Landau.cxx.

double derivBySigma ( double  x) const [private]

Calculates the derivative with respect to the sigma parameter.

Definition at line 194 of file Landau.cxx.

unsigned int dimensions ( ) const [virtual, inherited]

Returns the number of dimensions of the data coordinate.

This implementation in the base class returns 1. Derived class should override this function if the data coordinate is multi-dimensional.

Reimplemented in FunctionWrap.

Definition at line 213 of file FunctionBase.cxx.

const vector< double > & getParameters ( ) const [virtual, inherited]

Returns the values of the parameters as a vector.

The function is non-const because a derived class may need to create the vector.

Reimplemented in LinearSumFunction.

Definition at line 99 of file FunctionBase.cxx.

References FunctionBase::m_parms.

Referenced by FunctionProjector::saveParameters(), and FunctionProjector::setParameters().

bool hasDerivatives ( ) const [virtual]

Returns false since the derivatives have not been implemented.

Reimplemented from FunctionBase.

Definition at line 202 of file Landau.cxx.

void initialize ( ) [protected, virtual]

Initializes the function and parameter names.

Reimplemented from FunctionBase.

Definition at line 71 of file Landau.cxx.

void initialParameters ( const FunctionHelper helper) [virtual]

Sets the FunctionHelper so that the function can calculate a reasonable set of initial parameter values.

Reimplemented from FunctionBase.

Definition at line 153 of file Landau.cxx.

References FunctionHelper::maxValue(), FunctionHelper::meanCoord(), hippodraw::Numeric::norm(), and FunctionHelper::stdCoord().

double integrate ( double  a,
double  b 
) const [virtual, inherited]

Returns the integral of the function from the lower limit to the higher limit.

As of now all the integration is done here numerically using the trapezoidal rule. Derived class may implement an analytical expression in place of this numerical method.

Requests:
Override this method in derived classes when calculation of integral can be done analyically.
Requests:
Check if this is the best algorithm. Its looks different from the one found in http://osl.iu.edu/%7Etveldhui/papers/techniques/

Definition at line 138 of file FunctionBase.cxx.

References FunctionBase::operator()().

bool isComposite ( ) const [virtual, inherited]

Returns false.

Derived classes that are a composite of functions should override this member function and return true.

Reimplemented in LinearSumFunction.

Definition at line 161 of file FunctionBase.cxx.

const string & name ( ) const [inherited]
double operator() ( double  x) const [virtual]
double operator() ( const std::vector< double > &  v) const [virtual, inherited]

The function call operator for multi-dimension coordinate variable.

Returns the value of the function at coordinate represented by v. The implementation in this base class uses the first element of the vector and calls operator () ( double ).

Reimplemented in FunctionWrap.

Definition at line 181 of file FunctionBase.cxx.

References FunctionBase::operator()().

const vector< string > & parmNames ( ) const [virtual, inherited]

Returns a reference to a vector of parameter names.

Reimplemented in LinearSumFunction.

Definition at line 86 of file FunctionBase.cxx.

References FunctionBase::m_parm_names.

void removeFromComposite ( FunctionBase ) [virtual, inherited]

Does nothing.

Derived classes that are a composite of functions should override this member function and remove functions from the composite.

Reimplemented in LinearSumFunction.

Definition at line 170 of file FunctionBase.cxx.

void resize ( ) [protected, virtual, inherited]

Re-sizes the appropriate vectors maintained in this base class.

Derived classes should call this member function after initializing the m_parm_names data member, as the new size is taken from that data member's size.

Definition at line 71 of file FunctionBase.cxx.

References FunctionBase::m_parm_names, FunctionBase::m_parms, and FunctionBase::size().

Referenced by LogNormal::initialize(), Novosibirsk::initialize(), FunctionWrap::initialize(), FunctionWrap::setParmNames(), and FunctionBase::setParmNames().

void setName ( const char *  name) [protected, inherited]

Sets the name of the function.

Definition at line 66 of file FunctionBase.cxx.

References FunctionBase::m_name, and FunctionBase::name().

void setParameters ( const std::vector< double > &  incr) [virtual, inherited]

Sets the parameter values.

Derived classes should implement this function by invoking incrementValues ( vector< double >::const_iterator ) so that they correctly work with the LinearSumFunction class.

Definition at line 106 of file FunctionBase.cxx.

Referenced by FunctionProjector::restoreParameters(), and FunctionProjector::setParameters().

vector< double >::const_iterator setParameters ( std::vector< double >::const_iterator  it) [virtual, inherited]

Sets the parameter values to the value pointed to by the iterator.

Returns an iterator to a data element one past the last used data element.

Reimplemented in LinearSumFunction.

Definition at line 114 of file FunctionBase.cxx.

References FunctionBase::m_parms, and FunctionBase::size().

void setParmNames ( const std::vector< std::string > &  names) [inherited]

Sets the names of the parameters.

Reimplemented in FunctionWrap.

Definition at line 93 of file FunctionBase.cxx.

References FunctionBase::m_parm_names, and FunctionBase::resize().

int size ( ) const [virtual, inherited]

Returns the number of parameters.

Reimplemented in LinearSumFunction.

Definition at line 156 of file FunctionBase.cxx.

References FunctionBase::m_parm_names.

Referenced by Novosibirsk::initialParameters(), FunctionWrap::operator()(), FunctionBase::resize(), and FunctionBase::setParameters().


Member Data Documentation

std::string m_name [protected, inherited]
std::vector<std::string> m_parm_names [protected, inherited]
std::vector< double > m_parms [protected, inherited]

The documentation for this class was generated from the following files:

Generated for HippoDraw Class Library by doxygen