Alexandria  2.14.1
Please provide a description of the project.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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
TrayPosition
when looking for the position having a given value, one may encounter tray where the value is constan...
Definition: Cumulative.h:51
std::vector< double > m_x_sampling
Definition: Cumulative.h:154
Class for build cumulative from PDF and extract feature out of it.
Definition: Cumulative.h:41
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
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
std::vector< double > m_y_sampling
Definition: Cumulative.h:155
Cumulative & operator=(Cumulative &&other)
move assignation operator
Definition: Cumulative.cpp:36
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
void normalize()
Normalize the Cumulative. After calling this function the last vertical value is 1.0.
Definition: Cumulative.cpp:97
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
Cumulative(Cumulative &&other)
move constructor
Definition: Cumulative.cpp:34
This module provides an interface for accessing two dimensional datasets (pairs of (X...
Definition: XYDataset.h:59
virtual ~Cumulative()=default
Destructor.