libcrn
3.9.5
A document image processing library
|
Univariate Gaussian mixture. More...
#include <CRNUnivariateGaussianMixture.h>
Public Member Functions | |
UnivariateGaussianMixture () | |
Default constructor. More... | |
UnivariateGaussianMixture (const UnivariateGaussianMixture &m)=default | |
UnivariateGaussianMixture (UnivariateGaussianMixture &&)=default | |
template<typename ITER > | |
UnivariateGaussianMixture (ITER it_begin, ITER it_end, size_t nb_seeds=2) | |
virtual | ~UnivariateGaussianMixture () override |
Destructor. More... | |
UnivariateGaussianMixture & | operator= (const UnivariateGaussianMixture &)=delete |
UnivariateGaussianMixture & | operator= (UnivariateGaussianMixture &&)=default |
size_t | GetNbMembers () const noexcept |
Returns the number of density functions. More... | |
double | GetWeight (size_t k) const |
Returns the weight of a given density function. More... | |
UnivariateGaussianPDF | GetMember (size_t k) const |
Returns a given density function. More... | |
double | GetMean (size_t k) const |
Returns the mean of a given density function. More... | |
double | GetVariance (size_t k) const |
Returns the variance of a given density function. More... | |
void | AddMember (UnivariateGaussianPDF pdf, double Weight) |
Adds a density function. More... | |
void | SetMember (UnivariateGaussianPDF pdf, double w, size_t k) |
Replaces a given density function and its weight. More... | |
void | SortMembersByMeans (bool reverse=false) |
Sort members by means. More... | |
void | SortMembersByVariances (bool reverse=false) |
Sort members by means. More... | |
void | SortMembersByWeights (bool reverse=false) |
Sort members by weights. More... | |
double | ValueAt (const double x) const |
Evaluates a pattern. More... | |
double | ValueAt (const double x, size_t k, bool weight_flag=false) const |
Evaluates a pattern for a given density function. More... | |
unsigned int | EM (const MatrixDouble &patterns, size_t nbSeeds=2, double epsilon=std::numeric_limits< double >::epsilon(), size_t maximalIterations=100) |
Expectation Maximization. More... | |
unsigned int | EM (const std::vector< double > &patterns, size_t nbSeeds=2, double epsilon=std::numeric_limits< double >::epsilon(), size_t maximalIterations=100) |
Expectation Maximization. More... | |
template<typename ITER > | |
unsigned int | EM (ITER it_begin, ITER it_end, size_t nbSeeds=2, double epsilon=std::numeric_limits< double >::epsilon(), size_t maximalIterations=100) |
Expectation Maximization. More... | |
String | ToString () const |
Dumps a summary of the mixture to a string. More... | |
String | ToString (size_t k) const |
Dumps a summary of one element of the mixture to a string. More... | |
double | MLLE (const MatrixDouble &Data) const |
Maximum log-likelihood estimation. More... | |
double | MLLE (const std::vector< double > &Data) const |
Maximum log-likelihood estimation. More... | |
template<typename ITER > | |
double | MLLE (ITER it_begin, ITER it_end) const |
Maximum log-likelihood estimation. More... | |
double | BIC (double l, size_t n) const |
Bayes Information Criterion estimation. More... | |
double | BIC (const std::vector< double > &Data) const |
Bayes Information Criterion estimation. More... | |
std::vector< double > | MakeRandomSample (size_t n=1, size_t m=100, bool reseed=true) const |
Creates a data sample following the mixture's probability law. More... | |
void | Deserialize (xml::Element &el) |
xml::Element | Serialize (xml::Element &parent) const |
![]() | |
virtual | ~Object ()=default |
Univariate Gaussian mixture.
Model for univariate gaussian mixture
Definition at line 45 of file CRNUnivariateGaussianMixture.h.
|
inline |
Default constructor.
Definition at line 49 of file CRNUnivariateGaussianMixture.h.
|
default |
|
default |
|
inline |
Create a gaussian mixture to model a given set of data
[in] | it_begin | iterator pointing to first pair of input data |
[in] | it_end | ending iterator |
[in] | nbSeeds | the number of density functions |
Definition at line 61 of file CRNUnivariateGaussianMixture.h.
|
overridevirtual |
void UnivariateGaussianMixture::AddMember | ( | UnivariateGaussianPDF | pdf, |
double | w | ||
) |
Adds a density function.
Add a member in mixture
Definition at line 128 of file CRNUnivariateGaussianMixture.cpp.
|
inline |
Bayes Information Criterion estimation.
Definition at line 127 of file CRNUnivariateGaussianMixture.h.
|
inline |
Bayes Information Criterion estimation.
Definition at line 129 of file CRNUnivariateGaussianMixture.h.
void UnivariateGaussianMixture::Deserialize | ( | xml::Element & | el | ) |
Unsafe load from XML node
ExceptionInvalidArgument | not a UnivariateGaussianMixture |
ExceptionNotFound | cannot find attribute |
ExceptionDomain | wrong attribute |
[in] | el | the element to load |
Definition at line 739 of file CRNUnivariateGaussianMixture.cpp.
unsigned int UnivariateGaussianMixture::EM | ( | const MatrixDouble & | patterns, |
size_t | nbSeeds = 2 , |
||
double | epsilon = std::numeric_limits<double>::epsilon() , |
||
size_t | maximalIterations = 100 |
||
) |
Expectation Maximization.
Expectation-Maximization algorithm for Gaussian mixture estimation optimization
[in] | patterns | set of patterns stored as rows of a data matrix |
[in] | nbSeeds | integer |
[in] | epsilon | double |
[in] | maximalIterations | integer |
Definition at line 312 of file CRNUnivariateGaussianMixture.cpp.
unsigned int UnivariateGaussianMixture::EM | ( | const std::vector< double > & | patterns, |
size_t | nbSeeds = 2 , |
||
double | epsilon = std::numeric_limits<double>::epsilon() , |
||
size_t | maximalIterations = 100 |
||
) |
Expectation Maximization.
Expectation-Maximization algorithm for Gaussian mixture estimation optimization
[in] | patterns | set of patterns stored as standard vector |
[in] | nbSeeds | number of seeds |
[in] | epsilon | precision |
[in] | maximalIterations | maximal number of iterations |
Definition at line 458 of file CRNUnivariateGaussianMixture.cpp.
unsigned int crn::UnivariateGaussianMixture::EM | ( | ITER | it_begin, |
ITER | it_end, | ||
size_t | nbSeeds = 2 , |
||
double | epsilon = std::numeric_limits<double>::epsilon() , |
||
size_t | maximalIterations = 100 |
||
) |
Expectation Maximization.
Expectation-Maximization algorithm for Gaussian mixture estimation optimization
[in] | it_begin | iterator pointing to first double-size_t pair of input data |
[in] | it_end | ending iterator |
[in] | nbSeeds | number of seeds |
[in] | epsilon | precision |
[in] | maximalIterations | maximal number of iterations |
Definition at line 180 of file CRNUnivariateGaussianMixture.h.
double UnivariateGaussianMixture::GetMean | ( | size_t | k | ) | const |
Returns the mean of a given density function.
Get mean for a member
ExceptionDomain | index out of bounds |
[in] | k | integer |
Definition at line 91 of file CRNUnivariateGaussianMixture.cpp.
UnivariateGaussianPDF UnivariateGaussianMixture::GetMember | ( | size_t | k | ) | const |
Returns a given density function.
Get a member
ExceptionDomain | index out of bounds |
[in] | k | integer |
Definition at line 51 of file CRNUnivariateGaussianMixture.cpp.
|
inlinenoexcept |
Returns the number of density functions.
Definition at line 80 of file CRNUnivariateGaussianMixture.h.
double UnivariateGaussianMixture::GetVariance | ( | size_t | k | ) | const |
Returns the variance of a given density function.
Get variance for a member
ExceptionDomain | index out of bounds |
[in] | k | integer |
Definition at line 111 of file CRNUnivariateGaussianMixture.cpp.
double UnivariateGaussianMixture::GetWeight | ( | size_t | k | ) | const |
Returns the weight of a given density function.
Get weight for a member
ExceptionDomain | index out of bounds |
[in] | k | integer |
Definition at line 71 of file CRNUnivariateGaussianMixture.cpp.
std::vector< double > UnivariateGaussianMixture::MakeRandomSample | ( | size_t | n = 1 , |
size_t | m = 100 , |
||
bool | reseed = true |
||
) | const |
Creates a data sample following the mixture's probability law.
Simulate a random sample following the mixture's low
[in] | n | size of sample |
[in] | m | temporary sample size |
[in] | reseed | shall the random seed be reinitialized? |
Definition at line 603 of file CRNUnivariateGaussianMixture.cpp.
double UnivariateGaussianMixture::MLLE | ( | const MatrixDouble & | data | ) | const |
Maximum log-likelihood estimation.
Maximum log-likelyhood estimator
[in] | data | data stored as a column matrix |
Definition at line 273 of file CRNUnivariateGaussianMixture.cpp.
double UnivariateGaussianMixture::MLLE | ( | const std::vector< double > & | data | ) | const |
Maximum log-likelihood estimation.
Maximum log-likelyhood estimator
[in] | data | set of patterns stored as rows of a data matrix |
Definition at line 291 of file CRNUnivariateGaussianMixture.cpp.
double crn::UnivariateGaussianMixture::MLLE | ( | ITER | it_begin, |
ITER | it_end | ||
) | const |
Maximum log-likelihood estimation.
Maximum log-likelihood estimator
[in] | it_begin | iterator pointing to first double-size_t pair of input data |
[in] | it_end | ending iterator |
Definition at line 159 of file CRNUnivariateGaussianMixture.h.
|
delete |
|
default |
xml::Element UnivariateGaussianMixture::Serialize | ( | xml::Element & | parent | ) | const |
Unsafe save
[in] | parent | the parent element to which we will add the new element |
Definition at line 770 of file CRNUnivariateGaussianMixture.cpp.
void UnivariateGaussianMixture::SetMember | ( | UnivariateGaussianPDF | pdf, |
double | w, | ||
size_t | k | ||
) |
Replaces a given density function and its weight.
Set a member in mixture
ExceptionDomain | index out of bounds |
[in] | pointer to gaussian PDF to add as new member | |
[in] | w | Weight of the new member |
[in] | k | index |
Definition at line 142 of file CRNUnivariateGaussianMixture.cpp.
void UnivariateGaussianMixture::SortMembersByMeans | ( | bool | reverse = false | ) |
Sort members by means.
Sort members in mixture in increasing mean order
Definition at line 204 of file CRNUnivariateGaussianMixture.cpp.
void UnivariateGaussianMixture::SortMembersByVariances | ( | bool | reverse = false | ) |
Sort members by means.
Sort members in mixture in increasing mean order
Definition at line 212 of file CRNUnivariateGaussianMixture.cpp.
void UnivariateGaussianMixture::SortMembersByWeights | ( | bool | reverse = false | ) |
Sort members by weights.
Sort members in mixture in increasing weight
Definition at line 220 of file CRNUnivariateGaussianMixture.cpp.
String UnivariateGaussianMixture::ToString | ( | ) | const |
Dumps a summary of the mixture to a string.
Dump the mixture parameters to a string
Definition at line 688 of file CRNUnivariateGaussianMixture.cpp.
String UnivariateGaussianMixture::ToString | ( | size_t | k | ) | const |
Dumps a summary of one element of the mixture to a string.
Dump the parameters for one member in the mixture to a string
[in] | k | integer |
Definition at line 707 of file CRNUnivariateGaussianMixture.cpp.
double UnivariateGaussianMixture::ValueAt | ( | const double | x | ) | const |
Evaluates a pattern.
Evaluates an element
[in] | x | data argument to evaluate |
Definition at line 232 of file CRNUnivariateGaussianMixture.cpp.
double UnivariateGaussianMixture::ValueAt | ( | const double | x, |
size_t | k, | ||
bool | weight_flag = false |
||
) | const |
Evaluates a pattern for a given density function.
Evaluate only for one member of the mixture
ExceptionDomain | index out of bounds |
[in] | x | data argument to evaluate |
[in] | k | member index |
Definition at line 252 of file CRNUnivariateGaussianMixture.cpp.