Alexandria  2.27.0
SDC-CH common library for the Euclid project
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 More...
 
Cumulativeoperator= (Cumulative &&other)=default
 move assignation operator More...
 
 Cumulative (const Cumulative &other)=default
 copy constructor More...
 
Cumulativeoperator= (const Cumulative &other)=default
 copy assignation operator More...
 
 Cumulative (std::vector< double > &x_sampling, std::vector< double > &y_sampling)
 Constructor from the sampling of a cumulative. More...
 
 Cumulative (const XYDataset::XYDataset &sampling)
 Constructor from the sampling of a cumulative. More...
 
void normalize ()
 Normalize the Cumulative. After calling this function the last vertical value is 1.0. More...
 
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. More...
 
std::pair< double, double > 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. More...
 
std::pair< double, double > 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. More...
 
virtual ~Cumulative ()=default
 Destructor. More...
 

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. More...
 
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. More...
 

Private Attributes

std::vector< double > m_x_sampling
 
std::vector< double > m_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

Referenced by fromPdf().

◆ 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 33 of file Cumulative.cpp.

References std::vector< 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 40 of file Cumulative.cpp.

References Euclid::XYDataset::XYDataset::begin(), Euclid::XYDataset::XYDataset::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

◆ 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 163 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 127 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 87 of file Cumulative.cpp.

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

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 49 of file Cumulative.cpp.

References Euclid::XYDataset::XYDataset::begin(), Euclid::XYDataset::XYDataset::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 61 of file Cumulative.cpp.

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

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 75 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 154 of file Cumulative.h.

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

◆ m_y_sampling

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

Definition at line 155 of file Cumulative.h.

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


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