File: WeibullDistribution.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 (129 lines) | stat: -rw-r--r-- 5,095 bytes parent folder | download
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
//##########################################################################
//#                                                                        #
//#                               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 WEIBULL_DISTRIBUTION_HEADER
#define WEIBULL_DISTRIBUTION_HEADER

//Local
#include "GenericDistribution.h"

namespace CCLib
{

//! The Weibull statistical parametric distribution
/** Implementats the GenericDistribution interface.
**/
class CC_CORE_LIB_API WeibullDistribution : public GenericDistribution
{
public:

	//! WeibullDistribution constructor
	WeibullDistribution();

	//! WeibullDistribution constructor
	/** Distrubtion parameters can be directly set during object
		construction.
		\param a the Weibull a parameter (also known as 'k')
		\param b the Weibull b parameter (also known as 'lambda')
		\param valueShift a value shift ('zero')
	**/
	WeibullDistribution(ScalarType a, ScalarType b, ScalarType valueShift = 0);

	//! Returns the distribution parameters
	/** \param a the Weibull a parameter (also known as 'k')
		\param b the Weibull b parameter (also known as 'lambda')
		\return the parameters validity
	**/
	bool getParameters(ScalarType &a, ScalarType &b) const;

	//! Returns the normal distribution equivalent parameters
	/** \param mu a field to transmit the equivalent mean
		\param sigma2 a field to transmit the equivalent variance
		\return the parameters validity
	**/
	bool getOtherParameters(ScalarType &mu, ScalarType &sigma2) const;

	//! Returns the distribution 'mode'
	double computeMode() const;
	//! Returns the distribution 'skewness'
	double computeSkewness() const;

	//! Sets the distribution parameters
	/** \param a the Weibull a parameter (also known as 'k')
		\param b the Weibull b parameter (also known as 'lambda')
		\param valueShift a value shift ('zero')
		\return the parameters validity
	**/
	bool setParameters(ScalarType a, ScalarType b, ScalarType valueShift = 0);

	//! Sets the distribution value shift
	/** \param vs value shift
	**/
	void setValueShift(ScalarType vs);

	//! Returns the distribution value shift
	inline ScalarType getValueShift() const { return m_valueShift; }

	//inherited methods (see GenericDistribution)
	bool computeParameters(const ScalarContainer& values) override;
	double computeP(ScalarType x) const override;
	double computePfromZero(ScalarType x) const override;
	double computeP(ScalarType x1, ScalarType x2) const override;
	double computeChi2Dist(const GenericCloud* cloud, unsigned numberOfClasses, int* histo = nullptr) override;
	const char* getName() const override { return "Weibull"; }

protected:

	//! Compute each Chi2 class limits
	/** This method is used (internally) to accelerate the Chi2 distance computation.
		\param numberOfClasses the number of classes that will be used for Chi2 distance computation
		\return success
	**/
	virtual bool setChi2ClassesPositions(unsigned numberOfClasses);

	//! Chi2 classes limits
	/** Used internally. Stores both limits for each class in a vector
		(min_class_1, max_class_1, min_class_2, max_class_2, etc.).
	**/
	std::vector<ScalarType> chi2ClassesPositions;

	//! Parameters validity
	bool parametersDefined;
	//! Weibull distribution parameter a (k)
	ScalarType m_a;
	//! Weibull distribution parameter b (lambda)
	ScalarType m_b;
	//! Weibull distribution parameter 'value shift'
	ScalarType m_valueShift;

	//! Normal distribution equivalent parameter: mean
	ScalarType m_mu;
	//! Normal distribution equivalent parameter: variance
	ScalarType m_sigma2;

	//! internal function for parameters evaluation from sample points
	/** inverseVmax can be optionally specified for overflow-safe version
	**/
	static double ComputeG(const ScalarContainer& values, double a, ScalarType valueShift, double valueRange);
	//! internal function for parameters evaluation from sample points
	static double FindGRoot(const ScalarContainer& values, ScalarType valueShift, double valueRange);
};

}

#endif //WEIBULL_DISTRIBUTION_HEADER