Alexandria  2.16
Please provide a description of the project.
Cumulative.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2020 Euclid Science Ground Segment
3  *
4  * This library is free software; you can redistribute it and/or modify it under
5  * the terms of the GNU Lesser General Public License as published by the Free
6  * Software Foundation; either version 3.0 of the License, or (at your option)
7  * any later version.
8  *
9  * This library is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12  * details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this library; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
25 #ifndef _FUNCTIONUTILS_CUMULATIVE_H
26 #define _FUNCTIONUTILS_CUMULATIVE_H
27 
28 #include <vector>
29 #include <utility>
30 #include "XYDataset/XYDataset.h"
31 
32 namespace Euclid {
33 namespace MathUtils {
34 
41 class Cumulative {
42 
43 public:
52 
56  Cumulative ( Cumulative && other);
57 
61  Cumulative & operator = ( Cumulative && other);
62 
66  Cumulative(const Cumulative & other);
67 
71  Cumulative & operator = ( const Cumulative & other);
72 
80  Cumulative(std::vector<double>& x_sampling, std::vector<double>& y_sampling);
81 
87  explicit Cumulative(const XYDataset::XYDataset & sampling);
88 
98  static Cumulative fromPdf(std::vector<double>& x_sampling, std::vector<double>& pdf_sampling);
99 
107  static Cumulative fromPdf(const XYDataset::XYDataset & sampling);
108 
112  void normalize();
113 
125  double findValue(double ratio, TrayPosition position=TrayPosition::middle) const;
126 
134  std::pair<double,double> findMinInterval(double rate) const;
135 
146 
150  virtual ~Cumulative() = default;
151 
152 
153 private:
156 
157 
158 }; /* End of Cumulative class */
159 
160 } /* namespace MathUtils */
161 }
162 
163 #endif
Euclid::MathUtils::Cumulative::normalize
void normalize()
Normalize the Cumulative. After calling this function the last vertical value is 1....
Definition: Cumulative.cpp:97
Euclid::MathUtils::Cumulative::TrayPosition
TrayPosition
when looking for the position having a given value, one may encounter tray where the value is constan...
Definition: Cumulative.h:51
std::pair< double, double >
Euclid::XYDataset::XYDataset
This module provides an interface for accessing two dimensional datasets (pairs of (X,...
Definition: XYDataset.h:60
std::vector< double >
Euclid::MathUtils::Cumulative::m_y_sampling
std::vector< double > m_y_sampling
Definition: Cumulative.h:155
Euclid::MathUtils::Cumulative::fromPdf
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 p...
Definition: Cumulative.cpp:82
Euclid::MathUtils::Cumulative::m_x_sampling
std::vector< double > m_x_sampling
Definition: Cumulative.h:154
Euclid::MathUtils::Cumulative::findValue
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....
Definition: Cumulative.cpp:110
Euclid::MathUtils::Cumulative::operator=
Cumulative & operator=(Cumulative &&other)
move assignation operator
Definition: Cumulative.cpp:36
Euclid::MathUtils::Cumulative::Cumulative
Cumulative(Cumulative &&other)
move constructor
Definition: Cumulative.cpp:34
Euclid::MathUtils::Cumulative::findCenteredInterval
std::pair< double, double > findCenteredInterval(double rate) const
return the horizontal interval starting where the Cumulative has value (1-ratio)/2 and ending where t...
Definition: Cumulative.cpp:180
Euclid::MathUtils::Cumulative::middle
@ middle
Definition: Cumulative.h:51
Euclid::MathUtils::Cumulative::end
@ end
Definition: Cumulative.h:51
Euclid::MathUtils::Cumulative::findMinInterval
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 le...
Definition: Cumulative.cpp:141
Euclid
Definition: InstOrRefHolder.h:29
XYDataset.h
Euclid::MathUtils::Cumulative
Class for build cumulative from PDF and extract feature out of it.
Definition: Cumulative.h:41
Euclid::MathUtils::Cumulative::~Cumulative
virtual ~Cumulative()=default
Destructor.
Euclid::MathUtils::Cumulative::begin
@ begin
Definition: Cumulative.h:51