Alexandria 2.31.0
SDC-CH common library for the Euclid project
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
Euclid::MathUtils::Cumulative Class Reference

Class for build cumulative from PDF and extract feature out of it. More...

#include <Cumulative.h>

Collaboration diagram for Euclid::MathUtils::Cumulative:
Collaboration graph
[legend]

Public Types

enum  TrayPosition { begin , middle , end }
 when looking for the position having a given value, one may encounter tray where the value is constant on an interval. This enum allow to specify if one want an extremity or the middle of the tray. More...
 

Public Member Functions

 Cumulative (Cumulative &&other)=default
 move constructor
 
Cumulativeoperator= (Cumulative &&other)=default
 move assignation operator
 
 Cumulative (const Cumulative &other)=default
 copy constructor
 
Cumulativeoperator= (const Cumulative &other)=default
 copy assignation operator
 
 Cumulative (std::vector< double > &x_sampling, std::vector< double > &y_sampling)
 Constructor from the sampling of a cumulative.
 
 Cumulative (const XYDataset::XYDataset &sampling)
 Constructor from the sampling of a cumulative.
 
void normalize ()
 Normalize the Cumulative. After calling this function the last vertical value is 1.0.
 
double findValue (double ratio, TrayPosition position=TrayPosition::middle) const
 Find the first horizontal sample which vertical value is bigger or equal to the ratio value. If the Cumulative is not normalize the searched value is the last vertical value of the Cumulative time the ratio. If the selected sample is part of a tray (next sample(s) have the same vertical value), the position param allow to specify if the first, the last or the average of the point with the same value has to be returned.
 
std::pair< double, doublefindMinInterval (double rate) const
 Scan the horizontal axis looking for the smallest x-interval for which the vertical interval is at least rate*Last Value of the Cumulative.
 
std::pair< double, doublefindCenteredInterval (double rate) const
 return the horizontal interval starting where the Cumulative has value (1-ratio)/2 and ending where the Cumulative has value (1+ratio)/2. If the Cumulative is not normalized the searched value are multiplied by the last cumulative vertical value.
 
double eval (double x_value) const
 return the value of the cumulative at a given value of the horizontal axis. If the value do not match one of the knot a linear implementation is done.
 
virtual ~Cumulative ()=default
 Destructor.
 

Static Public Member Functions

static Cumulative fromPdf (std::vector< double > &x_sampling, std::vector< double > &pdf_sampling)
 Factory from the sampling of a PDF. The Cumulative vertical samples are build as the sum of the the pdf vertical sample with horizontal value smaller or equal to the cumulative horizontal value.
 
static Cumulative fromPdf (const XYDataset::XYDataset &sampling)
 Factory from the sampling of a PDF. The Cumulative vertical samples are build as the sum of the the pdf vertical sample with horizontal value smaller or equal to the cumulative horizontal value.
 

Private Attributes

std::vector< doublem_x_sampling
 
std::vector< doublem_y_sampling
 

Detailed Description

Class for build cumulative from PDF and extract feature out of it.

Definition at line 41 of file Cumulative.h.

Member Enumeration Documentation

◆ TrayPosition

when looking for the position having a given value, one may encounter tray where the value is constant on an interval. This enum allow to specify if one want an extremity or the middle of the tray.

Enumerator
begin 
middle 
end 

Definition at line 51 of file Cumulative.h.

Constructor & Destructor Documentation

◆ Cumulative() [1/4]

Euclid::MathUtils::Cumulative::Cumulative ( Cumulative &&  other)
default

move constructor

◆ Cumulative() [2/4]

Euclid::MathUtils::Cumulative::Cumulative ( const Cumulative other)
default

copy constructor

◆ Cumulative() [3/4]

Euclid::MathUtils::Cumulative::Cumulative ( std::vector< double > &  x_sampling,
std::vector< double > &  y_sampling 
)

Constructor from the sampling of a cumulative.

Parameters
x_samplinghorizontal sampling.
y_samplingvertical sampling.
Exceptions
Exceptionif the 2 axis have not the same length

Definition at line 34 of file Cumulative.cpp.

References std::array< T >::size().

Here is the call graph for this function:

◆ Cumulative() [4/4]

Euclid::MathUtils::Cumulative::Cumulative ( const XYDataset::XYDataset sampling)
explicit

Constructor from the sampling of a cumulative.

Parameters
samplingcumulative sampling.

Definition at line 41 of file Cumulative.cpp.

References std::array< T >::begin(), std::array< T >::end(), m_x_sampling, m_y_sampling, and std::vector< T >::push_back().

Here is the call graph for this function:

◆ ~Cumulative()

virtual Euclid::MathUtils::Cumulative::~Cumulative ( )
virtualdefault

Destructor.

Member Function Documentation

◆ eval()

double Euclid::MathUtils::Cumulative::eval ( double  x_value) const

return the value of the cumulative at a given value of the horizontal axis. If the value do not match one of the knot a linear implementation is done.

Parameters
x_valuevalue at which the cumulative must be evaluated.
Returns
the value of the

Definition at line 204 of file Cumulative.cpp.

References Euclid::MathUtils::interpolate(), Euclid::MathUtils::LINEAR, m_x_sampling, m_y_sampling, and std::vector< T >::size().

Here is the call graph for this function:

◆ findCenteredInterval()

std::pair< double, double > Euclid::MathUtils::Cumulative::findCenteredInterval ( double  rate) const

return the horizontal interval starting where the Cumulative has value (1-ratio)/2 and ending where the Cumulative has value (1+ratio)/2. If the Cumulative is not normalized the searched value are multiplied by the last cumulative vertical value.

Parameters
rateVertical interval,
Returns
a pair of number the first is the horizontal value of the begining of the interval, the second the end.

Definition at line 164 of file Cumulative.cpp.

References std::vector< T >::back(), std::vector< T >::begin(), std::vector< T >::cbegin(), std::vector< T >::cend(), m_x_sampling, m_y_sampling, and std::make_pair().

Here is the call graph for this function:

◆ findMinInterval()

std::pair< double, double > Euclid::MathUtils::Cumulative::findMinInterval ( double  rate) const

Scan the horizontal axis looking for the smallest x-interval for which the vertical interval is at least rate*Last Value of the Cumulative.

Parameters
rateVertical interval,
Returns
a pair of number the first is the horizontal value of the begining of the interval, the second the end.

Definition at line 128 of file Cumulative.cpp.

References std::vector< T >::back(), std::vector< T >::cbegin(), std::vector< T >::cend(), std::vector< T >::front(), m_x_sampling, m_y_sampling, and std::make_pair().

Here is the call graph for this function:

◆ findValue()

double Euclid::MathUtils::Cumulative::findValue ( double  ratio,
TrayPosition  position = TrayPosition::middle 
) const

Find the first horizontal sample which vertical value is bigger or equal to the ratio value. If the Cumulative is not normalize the searched value is the last vertical value of the Cumulative time the ratio. If the selected sample is part of a tray (next sample(s) have the same vertical value), the position param allow to specify if the first, the last or the average of the point with the same value has to be returned.

Parameters
ratioThe value to be searched,
positionSelection of the returned value in case of tray,
Returns
the horizontal value for which the Cumulative has the vertical value ratio.

Definition at line 88 of file Cumulative.cpp.

References std::vector< T >::back(), begin, std::vector< T >::cbegin(), std::vector< T >::cend(), end, m_x_sampling, m_y_sampling, and middle.

Here is the call graph for this function:

◆ fromPdf() [1/2]

Cumulative Euclid::MathUtils::Cumulative::fromPdf ( const XYDataset::XYDataset sampling)
static

Factory from the sampling of a PDF. The Cumulative vertical samples are build as the sum of the the pdf vertical sample with horizontal value smaller or equal to the cumulative horizontal value.

Parameters
samplingpdf sampling.

Definition at line 50 of file Cumulative.cpp.

References std::array< T >::begin(), std::array< T >::end(), and fromPdf().

Here is the call graph for this function:

◆ fromPdf() [2/2]

Cumulative Euclid::MathUtils::Cumulative::fromPdf ( std::vector< double > &  x_sampling,
std::vector< double > &  pdf_sampling 
)
static

Factory from the sampling of a PDF. The Cumulative vertical samples are build as the sum of the the pdf vertical sample with horizontal value smaller or equal to the cumulative horizontal value.

Parameters
x_samplingpdf horizontal sampling.
y_samplingpdf vertical sampling.
Exceptions
Exceptionif the 2 axis have not the same length

Definition at line 62 of file Cumulative.cpp.

References std::array< T >::cbegin(), and std::array< T >::cend().

Referenced by fromPdf().

Here is the call graph for this function:

◆ normalize()

void Euclid::MathUtils::Cumulative::normalize ( )

Normalize the Cumulative. After calling this function the last vertical value is 1.0.

Definition at line 76 of file Cumulative.cpp.

References std::vector< T >::back(), std::vector< T >::begin(), std::vector< T >::end(), m_y_sampling, and std::move().

Here is the call graph for this function:

◆ operator=() [1/2]

Cumulative & Euclid::MathUtils::Cumulative::operator= ( const Cumulative other)
default

copy assignation operator

◆ operator=() [2/2]

Cumulative & Euclid::MathUtils::Cumulative::operator= ( Cumulative &&  other)
default

move assignation operator

Member Data Documentation

◆ m_x_sampling

std::vector<double> Euclid::MathUtils::Cumulative::m_x_sampling
private

Definition at line 163 of file Cumulative.h.

Referenced by Cumulative(), eval(), findCenteredInterval(), findMinInterval(), and findValue().

◆ m_y_sampling

std::vector<double> Euclid::MathUtils::Cumulative::m_y_sampling
private

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