ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
GenericDistribution.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 // Local
11 #include "CVCoreLib.h"
12 #include "CVTypes.h"
13 
14 // system
15 #include <vector>
16 
17 namespace cloudViewer {
18 
19 class GenericCloud;
20 
22 
26 public:
28  GenericDistribution() : m_isValid(false) {}
29 
31  virtual ~GenericDistribution() = default;
32 
34  virtual const char* getName() const = 0;
35 
37 
43  virtual bool isValid() const { return m_isValid; }
44 
46  using ScalarContainer = std::vector<ScalarType>;
47 
49 
52  virtual bool computeParameters(const ScalarContainer& values) = 0;
53 
55 
58  virtual double computeP(ScalarType x) const = 0;
59 
61 
64  virtual double computePfromZero(ScalarType x) const = 0;
65 
67 
72  virtual double computeP(ScalarType x1, ScalarType x2) const = 0;
73 
75 
87  virtual double computeChi2Dist(const GenericCloud* Yk,
88  unsigned numberOfClasses,
89  int* histo = nullptr) = 0;
90 
91 protected:
93  void setValid(bool state) { m_isValid = state; }
94 
96  bool m_isValid;
97 };
98 
99 } // namespace cloudViewer
#define CV_CORE_LIB_API
Definition: CVCoreLibWin.h:15
A generic class to handle a probability distribution.
virtual double computeP(ScalarType x) const =0
Computes the probability of x.
virtual bool computeParameters(const ScalarContainer &values)=0
Computes the distribution parameters from a set of values.
virtual double computeP(ScalarType x1, ScalarType x2) const =0
Computes the cumulative probability between x1 and x2.
virtual double computeChi2Dist(const GenericCloud *Yk, unsigned numberOfClasses, int *histo=nullptr)=0
Computes the Chi2 distance (related to the Chi2 Test)
virtual ~GenericDistribution()=default
Default destructor.
virtual const char * getName() const =0
Returns distribution name.
virtual bool isValid() const
Indicates if the distribution parameters are valid.
void setValid(bool state)
Sets distribution current validity.
GenericDistribution()
Default constructor.
bool m_isValid
Whether the distribution is in a valid state or not.
std::vector< ScalarType > ScalarContainer
Scalar values container.
virtual double computePfromZero(ScalarType x) const =0
Computes the cumulative probability between 0 and x.
Generic file read and write utility for python interface.