GClasses
|
This is a distribution that specifies a probability for each value in a set of nominal values. More...
#include <GDistribution.h>
Public Member Functions | |
GCategoricalDistribution () | |
virtual | ~GCategoricalDistribution () |
void | deserialize (GDomNode *pNode) |
Load values from a text format. | |
GDomNode * | serialize (GDom *pDoc) |
Save values to a text format. | |
virtual Type | type () const |
Returns categorical. | |
virtual bool | isDiscrete () const |
Returns true. | |
virtual bool | isSupported (double x) const |
Returns true if x is within the range of support. If x is not an integer, it will round x to the nearest integer and then return true if that value is supported. | |
virtual double | mode () const |
Returns the mode. | |
virtual double | logLikelihood (double x) |
See the comment for GUnivariateDistribution::logLikelihood. | |
virtual double | likelihood (double x) |
See the comment for GUnivariateDistribution::likelihood. | |
size_t | valueCount () |
Returns the number of supported values. | |
double * | values (size_t nValueCount) |
Resizes the vector of probabilities if it does not have nValueCount elements, and returns that vector. | |
double | normalizedEntropy () |
Computes the entropy of the values, normalized to fall between 0 and 1. | |
void | normalize () |
Makes the values sum to 1, and finds the mode. | |
void | normalizeFromLogSpace () |
Safely converts from log space, and then normalizes. | |
void | setValues (size_t nValueCount, const double *pValues) |
Sets the specified values, and normalizes. | |
void | setToUniform (size_t nValues) |
Set all uniform probabilities. | |
void | setBoolean (double d) |
(1-d) is the probability of 0, and d is the probability of 1 | |
void | setSpike (size_t nValueCount, size_t nValue, size_t nDepth) |
This is a hack for when you know the mode but you don't know the other values. | |
double | entropy () |
Returns the entropy of the values. | |
Protected Attributes | |
size_t | m_nValueCount |
size_t | m_nMode |
double * | m_pValues |
This is a distribution that specifies a probability for each value in a set of nominal values.
GClasses::GCategoricalDistribution::GCategoricalDistribution | ( | ) | [inline] |
virtual GClasses::GCategoricalDistribution::~GCategoricalDistribution | ( | ) | [inline, virtual] |
void GClasses::GCategoricalDistribution::deserialize | ( | GDomNode * | pNode | ) |
Load values from a text format.
double GClasses::GCategoricalDistribution::entropy | ( | ) |
Returns the entropy of the values.
virtual bool GClasses::GCategoricalDistribution::isDiscrete | ( | ) | const [inline, virtual] |
Returns true.
Implements GClasses::GUnivariateDistribution.
virtual bool GClasses::GCategoricalDistribution::isSupported | ( | double | x | ) | const [virtual] |
Returns true if x is within the range of support. If x is not an integer, it will round x to the nearest integer and then return true if that value is supported.
Implements GClasses::GUnivariateDistribution.
virtual double GClasses::GCategoricalDistribution::likelihood | ( | double | x | ) | [inline, virtual] |
See the comment for GUnivariateDistribution::likelihood.
Implements GClasses::GUnivariateDistribution.
virtual double GClasses::GCategoricalDistribution::logLikelihood | ( | double | x | ) | [virtual] |
See the comment for GUnivariateDistribution::logLikelihood.
Implements GClasses::GUnivariateDistribution.
virtual double GClasses::GCategoricalDistribution::mode | ( | ) | const [inline, virtual] |
Returns the mode.
Implements GClasses::GUnivariateDistribution.
void GClasses::GCategoricalDistribution::normalize | ( | ) |
Makes the values sum to 1, and finds the mode.
double GClasses::GCategoricalDistribution::normalizedEntropy | ( | ) | [inline] |
Computes the entropy of the values, normalized to fall between 0 and 1.
void GClasses::GCategoricalDistribution::normalizeFromLogSpace | ( | ) |
Safely converts from log space, and then normalizes.
Save values to a text format.
void GClasses::GCategoricalDistribution::setBoolean | ( | double | d | ) | [inline] |
(1-d) is the probability of 0, and d is the probability of 1
void GClasses::GCategoricalDistribution::setSpike | ( | size_t | nValueCount, |
size_t | nValue, | ||
size_t | nDepth | ||
) |
This is a hack for when you know the mode but you don't know the other values.
void GClasses::GCategoricalDistribution::setToUniform | ( | size_t | nValues | ) | [inline] |
Set all uniform probabilities.
void GClasses::GCategoricalDistribution::setValues | ( | size_t | nValueCount, |
const double * | pValues | ||
) |
Sets the specified values, and normalizes.
virtual Type GClasses::GCategoricalDistribution::type | ( | ) | const [inline, virtual] |
Returns categorical.
Implements GClasses::GUnivariateDistribution.
size_t GClasses::GCategoricalDistribution::valueCount | ( | ) | [inline] |
Returns the number of supported values.
double* GClasses::GCategoricalDistribution::values | ( | size_t | nValueCount | ) | [inline] |
Resizes the vector of probabilities if it does not have nValueCount elements, and returns that vector.
size_t GClasses::GCategoricalDistribution::m_nMode [protected] |
size_t GClasses::GCategoricalDistribution::m_nValueCount [protected] |
double* GClasses::GCategoricalDistribution::m_pValues [protected] |