File: GenericDistribution.h

package info (click to toggle)
cloudcompare 2.11.3-7.1
  • links: PTS
  • area: main
  • in suites: bookworm
  • size: 58,224 kB
  • sloc: cpp: 229,982; ansic: 30,723; makefile: 84; sh: 20
file content (114 lines) | stat: -rw-r--r-- 4,444 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
//##########################################################################
//#                                                                        #
//#                               CCLIB                                    #
//#                                                                        #
//#  This program is free software; you can redistribute it and/or modify  #
//#  it under the terms of the GNU Library General Public License as       #
//#  published by the Free Software Foundation; version 2 or later of the  #
//#  License.                                                              #
//#                                                                        #
//#  This program is distributed in the hope that it will be useful,       #
//#  but WITHOUT ANY WARRANTY; without even the implied warranty of        #
//#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the          #
//#  GNU General Public License for more details.                          #
//#                                                                        #
//#          COPYRIGHT: EDF R&D / TELECOM ParisTech (ENST-TSI)             #
//#                                                                        #
//##########################################################################

#ifndef GENERIC_DISTRIBUTION_HEADER
#define GENERIC_DISTRIBUTION_HEADER

//Local
#include "CCCoreLib.h"
#include "CCTypes.h"

//system
#include <vector>

namespace CCLib
{

class GenericCloud;

//! A generic class to handle a probability distribution
/** Custom parametric distributions can be implemented through this
	interface and used for filtering data (see StatisticalTestingTools).
**/
class CC_CORE_LIB_API GenericDistribution
{
public:

	//! Default constructor
	GenericDistribution() : m_isValid(false) {}

	//! Default destructor
	virtual ~GenericDistribution() = default;

	//! Returns distribution name
	virtual const char* getName() const = 0; 

	//! Indicates if the distribution parameters are valid
	/** This function is related to 'computeParameters()'. If the parameters
		computation failed, then the parameters will be marked as 'invalid'. In this
		case, the dsitribution should'nt be used (most of the methods won't work anyway).
		\return true (if the distribution parameters are valid) or false (if not)
	**/
	virtual bool isValid() const { return m_isValid; }

	//! Scalar values container
	using ScalarContainer = std::vector<ScalarType>;

	//! Computes the distribution parameters from a set of values
	/**	\param values a set of scalar values
		\return true (if the computation succeeded) or false (if not)
	**/
	virtual bool computeParameters(const ScalarContainer& values) = 0;

	//! Computes the probability of x
	/** \param x the variable
		\return the probabilty
	**/
	virtual double computeP(ScalarType x) const = 0;

	//! Computes the cumulative probability between 0 and x
	/** \param x the upper boundary
		\return the cumulative probabilty
	**/
	virtual double computePfromZero(ScalarType x) const = 0;

	//! Computes the cumulative probability between x1 and x2
	/** x1 should be lower than x2
		\param x1 the lower boundary
		\param x2 the upper boundary
		\return the cumulative probabilty
	**/
	virtual double computeP(ScalarType x1, ScalarType x2) const = 0;

	//! Computes the Chi2 distance (related to the Chi2 Test)
	/** Computes the Chi2 distance from a group of point, accordingly to
		a certain number of classes (see Chi2 test theory for more information).
		The result of projecting each point (or more precisely each scalar value
		associated to each point) in the different classes can be stored in an array
		(of the same size as the number of classes). To do so, such an array (already
		allocated in memory) should be passed as an argument.
		Warning: be sure to activate an OUTPUT scalar field on the input cloud
		\param Yk a group of points
		\param numberOfClasses the number of classes for the Chi2 Test
		\param histo an array to store the values projection result (optional)
		\return the Chi2 distance (or -1.0 if an error occurred)
	**/
	virtual double computeChi2Dist(const GenericCloud* Yk, unsigned numberOfClasses, int* histo = nullptr) = 0;

protected:

	//! Sets distribution current validity
	void setValid(bool state) { m_isValid = state; }

	//! Whether the distribution is in a valid state or not
	bool m_isValid;
};

}

#endif //GENERIC_DISTRIBUTION_HEADER