GeneticAlgoithm
Implementation of the genetic algorithm
Public Member Functions | Protected Attributes | List of all members
Chi2FitFigureOfMerit Class Reference

Class implementing a \(\chi^2/ndf\) figure of merit. More...

#include <Chi2FitFigureOfMerit.h>

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

Public Member Functions

 Chi2FitFigureOfMerit ()
 
 ~Chi2FitFigureOfMerit ()
 
void addData (const std::vector< double > &x, double y, double ey)
 
void clearData ()
 
double evaluate (IModel *model) const
 
bool isBetterThan (double scoreToTest, double referenceScore) const
 
- Public Member Functions inherited from IFigureOfMerit
 IFigureOfMerit ()
 
virtual ~IFigureOfMerit ()
 
virtual bool accept (IModel *model) const
 
virtual bool isBetterThan (IModel *scoreToTest, IModel *referenceModel) const
 
void setAcceptThreshold (double acceptThreshold)
 
double getAcceptThreshold () const
 

Protected Attributes

std::vector< std::vector< double > > m_x
 Stores the \(\vec{x_i}\) coordinates.
 
std::vector< double > m_y
 Stores the \(y_i\) coordinates.
 
std::vector< double > m_ey
 Stores the \(\sigma_{y_i}\) errors.
 
- Protected Attributes inherited from IFigureOfMerit
double m_acceptThreshold
 Stores the score threshold to accept a model as a final answer.
 

Additional Inherited Members

- Protected Member Functions inherited from IFigureOfMerit
virtual bool accept (double scrore) const
 

Detailed Description

Class implementing a \(\chi^2/ndf\) figure of merit.

The \(\chi^2/ndf\) is computed by comparing a model to a dataset:

Definition at line 21 of file Chi2FitFigureOfMerit.h.

Constructor & Destructor Documentation

◆ Chi2FitFigureOfMerit()

Chi2FitFigureOfMerit::Chi2FitFigureOfMerit ( )

Default Constructor

Definition at line 8 of file Chi2FitFigureOfMerit.cxx.

◆ ~Chi2FitFigureOfMerit()

Chi2FitFigureOfMerit::~Chi2FitFigureOfMerit ( )

Destructor

Definition at line 14 of file Chi2FitFigureOfMerit.cxx.

Member Function Documentation

◆ addData()

void Chi2FitFigureOfMerit::addData ( const std::vector< double > &  x,
double  y,
double  ey 
)

Adds a data point

Parameters
x\(\vec{x}\) coordinate.
y\(y\) coordinate.
ey\(\sigma_y\) error on \(y\) coordinate.

Definition at line 23 of file Chi2FitFigureOfMerit.cxx.

◆ clearData()

void Chi2FitFigureOfMerit::clearData ( )

Clear all data

Definition at line 30 of file Chi2FitFigureOfMerit.cxx.

◆ evaluate()

double Chi2FitFigureOfMerit::evaluate ( IModel imodel) const
virtual

Compute the score ( \(\chi^2/ndf\)) for a given model relative to the data points.

Parameters
imodelModel to be evaluated.
Returns
\(\chi^2/ndf\) score.

The \(\chi^2/ndf\) score is then defined as:

\[ \chi^2/ndf = \frac{1}{N}\sum_{i=0}^N \frac{(y_i - f(\vec{x_i}))^2}{\sigma_{y_i}^2} \]

Implements IFigureOfMerit.

Definition at line 46 of file Chi2FitFigureOfMerit.cxx.

◆ isBetterThan()

bool Chi2FitFigureOfMerit::isBetterThan ( double  scoreToTest,
double  referenceScore 
) const
virtual

Compares two score values

Parameters
scoreToTestScore value to be tested.
referenceScoreScore value to be compared to.
Returns
true if scoreToTest < referenceScore

Reimplemented from IFigureOfMerit.

Definition at line 76 of file Chi2FitFigureOfMerit.cxx.


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