Alexandria  2.25.0
SDC-CH common library for the Euclid project
Cumulative.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2021 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 "XYDataset/XYDataset.h"
29 #include <utility>
30 #include <vector>
31 
32 namespace Euclid {
33 namespace MathUtils {
34 
41 class Cumulative {
42 
43 public:
52 
56  Cumulative(Cumulative&& other);
57 
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 
126  double findValue(double ratio, TrayPosition position = TrayPosition::middle) const;
127 
135  std::pair<double, double> findMinInterval(double rate) const;
136 
147 
151  virtual ~Cumulative() = default;
152 
153 private:
156 
157 }; /* End of Cumulative class */
158 
159 } /* namespace MathUtils */
160 } // namespace Euclid
161 
162 #endif
Class for build cumulative from PDF and extract feature out of it.
Definition: Cumulative.h:41
TrayPosition
when looking for the position having a given value, one may encounter tray where the value is constan...
Definition: Cumulative.h:51
virtual ~Cumulative()=default
Destructor.
std::vector< double > m_x_sampling
Definition: Cumulative.h:154
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
std::vector< double > m_y_sampling
Definition: Cumulative.h:155
Cumulative(Cumulative &&other)
move constructor
Definition: Cumulative.cpp:33
Cumulative & operator=(Cumulative &&other)
move assignation operator
Definition: Cumulative.cpp:36
void normalize()
Normalize the Cumulative. After calling this function the last vertical value is 1....
Definition: Cumulative.cpp:92
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:104
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:144
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:78
This module provides an interface for accessing two dimensional datasets (pairs of (X,...
Definition: XYDataset.h:59