Alexandria  2.25.0
SDC-CH common library for the Euclid project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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)
 move constructor More...
 
Cumulativeoperator= (Cumulative &&other)
 move assignation operator More...
 
 Cumulative (const Cumulative &other)
 copy constructor More...
 
Cumulativeoperator= (const Cumulative &other)
 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

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

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

move constructor

Definition at line 33 of file Cumulative.cpp.

Referenced by fromPdf().

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

copy constructor

Definition at line 42 of file Cumulative.cpp.

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

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

Here is the call graph for this function:

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

Constructor from the sampling of a cumulative.

Parameters
samplingcumulative sampling.

Definition at line 57 of file Cumulative.cpp.

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

Destructor.

Member Function Documentation

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 180 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:

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 144 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:

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 104 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:

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 78 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:

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

References Euclid::XYDataset::XYDataset::begin(), Euclid::XYDataset::XYDataset::end(), and fromPdf().

Here is the call graph for this function:

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

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

Definition at line 92 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:

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

move assignation operator

Definition at line 36 of file Cumulative.cpp.

References m_x_sampling, m_y_sampling, and std::move().

Here is the call graph for this function:

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

copy assignation operator

Definition at line 44 of file Cumulative.cpp.

References m_x_sampling, and m_y_sampling.

Member Data Documentation

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

Definition at line 154 of file Cumulative.h.

Referenced by findCenteredInterval(), findMinInterval(), findValue(), and operator=().

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

Definition at line 155 of file Cumulative.h.

Referenced by findCenteredInterval(), findMinInterval(), findValue(), normalize(), and operator=().


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