Alexandria 2.31.0
SDC-CH common library for the Euclid project
|
Class for build cumulative from PDF and extract feature out of it. More...
#include <Cumulative.h>
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 | |
Cumulative & | operator= (Cumulative &&other)=default |
move assignation operator | |
Cumulative (const Cumulative &other)=default | |
copy constructor | |
Cumulative & | operator= (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, 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. | |
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. | |
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< double > | m_x_sampling |
std::vector< double > | m_y_sampling |
Class for build cumulative from PDF and extract feature out of it.
Definition at line 41 of file Cumulative.h.
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.
|
default |
move constructor
|
default |
copy constructor
Euclid::MathUtils::Cumulative::Cumulative | ( | std::vector< double > & | x_sampling, |
std::vector< double > & | y_sampling | ||
) |
Constructor from the sampling of a cumulative.
x_sampling | horizontal sampling. |
y_sampling | vertical sampling. |
Exception | if the 2 axis have not the same length |
Definition at line 34 of file Cumulative.cpp.
References std::array< T >::size().
|
explicit |
Constructor from the sampling of a cumulative.
sampling | cumulative 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().
|
virtualdefault |
Destructor.
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.
x_value | value at which the cumulative must be evaluated. |
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().
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.
rate | Vertical interval, |
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().
Scan the horizontal axis looking for the smallest x-interval for which the vertical interval is at least rate*Last Value of the Cumulative.
rate | Vertical interval, |
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().
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.
ratio | The value to be searched, |
position | Selection of the returned value in case of tray, |
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.
|
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.
sampling | pdf sampling. |
Definition at line 50 of file Cumulative.cpp.
References std::array< T >::begin(), std::array< T >::end(), and fromPdf().
|
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.
x_sampling | pdf horizontal sampling. |
y_sampling | pdf vertical sampling. |
Exception | if 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().
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().
|
default |
copy assignation operator
|
default |
move assignation operator
|
private |
Definition at line 163 of file Cumulative.h.
Referenced by Cumulative(), eval(), findCenteredInterval(), findMinInterval(), and findValue().
|
private |
Definition at line 164 of file Cumulative.h.
Referenced by Cumulative(), eval(), findCenteredInterval(), findMinInterval(), findValue(), and normalize().