pbl::PMF Class Reference
This class represents a discrete probability distribution (or probability mass function). Currently, this PMF can only take strings as values.
More...
#include <PMF.h>
List of all members.
Classes |
struct | PMFStruct |
Public Member Functions |
PMF * | clone () const |
| Creates a clone of the object. The clone method is cheap since it only copies a pointer. A deep clone will only be created if the original object is modified.
|
double | getDensity (const arma::vec &v) const |
int | getDomainSize () const |
| Returns the domain size of this distribution.
|
bool | getExpectedValue (std::string &v) const |
| Returns in parameter v the expected value for this distribution, i.e., the value with the highest probability.
|
double | getLikelihood (const PMF &pmf) const |
double | getLikelihood (const PDF &pdf) const |
double | getMaxDensity () const |
std::string | getMostProbableValue () const |
void | getProbabilities (std::vector< double > &probabilities) const |
| Returns all probabilities of the known values.
|
double | getProbability (const std::string &value, int domain_size) const |
| Returns the probability of the given value, for a given domain_size. The domain size determines the probability if the value is unknown, in which case a uniform distribution over all unknown values is assumed.
|
double | getProbability (const std::string &value) const |
| Returns the probability of the given value.
|
double | getProbabilityUnknown (int domain_size) const |
double | getProbabilityUnknown () const |
void | getValues (std::vector< std::string > &values) const |
| Returns a vector of values for which a probability is specified.
|
void | normalize () |
PMF & | operator= (const PMF &other) |
| Assignment operator. The operation is cheap since it only copies a pointer. A deep clone will only be created if the original object is modified.
|
| PMF (const PMF &pmf) |
| Copy constructor.
|
| PMF (int domain_size=-1) |
| Constructs a discrete probability distribution. The optional parameter domain size states the number of possible values of the random variable underlying this distribution, and determines the probability of unknown values if the probabilities of all unknown values do not sum up to one.
|
void | setDomainSize (int domain_size) |
| Sets the domain size of this discrete distribution.
|
void | setExact (const std::string &value) |
| Set the probability of the given value to 1. All other values are given a probability of 0.
|
void | setProbability (const std::string &value, double p) |
| Set the probability of a given value.
|
std::string | toString (const std::string &indent="") const |
| Represents the PMF as a string for easier console output.
|
void | update (const pbl::PMF &pmf) |
virtual | ~PMF () |
| Destructor.
|
Protected Member Functions |
void | cloneStruct () |
Protected Attributes |
PMFStruct * | ptr_ |
Detailed Description
This class represents a discrete probability distribution (or probability mass function). Currently, this PMF can only take strings as values.
- Author:
- Sjoerd van den Dries
- Date:
- December, 2012
- Version:
- 1.0
Definition at line 52 of file PMF.h.
Constructor & Destructor Documentation
PMF::PMF |
( |
int |
domain_size = -1 |
) |
|
Constructs a discrete probability distribution. The optional parameter domain size states the number of possible values of the random variable underlying this distribution, and determines the probability of unknown values if the probabilities of all unknown values do not sum up to one.
- Parameters:
-
| domain_size | The number of values the random variable of this pmf can take |
Definition at line 41 of file PMF.cpp.
PMF::PMF |
( |
const PMF & |
pmf |
) |
|
Copy constructor.
Definition at line 44 of file PMF.cpp.
Destructor.
Definition at line 50 of file PMF.cpp.
Member Function Documentation
PMF * PMF::clone |
( |
|
) |
const [virtual] |
Creates a clone of the object. The clone method is cheap since it only copies a pointer. A deep clone will only be created if the original object is modified.
Implements pbl::PDF.
Definition at line 75 of file PMF.cpp.
void PMF::cloneStruct |
( |
|
) |
[protected] |
double PMF::getDensity |
( |
const arma::vec & |
v |
) |
const |
int PMF::getDomainSize |
( |
|
) |
const |
Returns the domain size of this distribution.
Definition at line 252 of file PMF.cpp.
bool PMF::getExpectedValue |
( |
std::string & |
v |
) |
const [virtual] |
Returns in parameter v the expected value for this distribution, i.e., the value with the highest probability.
- Returns:
- Whether an expected value was found
Reimplemented from pbl::PDF.
Definition at line 136 of file PMF.cpp.
double PMF::getLikelihood |
( |
const PMF & |
pmf |
) |
const |
double PMF::getLikelihood |
( |
const PDF & |
pdf |
) |
const [virtual] |
double PMF::getMaxDensity |
( |
|
) |
const [virtual] |
std::string PMF::getMostProbableValue |
( |
|
) |
const |
void PMF::getProbabilities |
( |
std::vector< double > & |
probabilities |
) |
const |
Returns all probabilities of the known values.
Definition at line 130 of file PMF.cpp.
double PMF::getProbability |
( |
const std::string & |
value, |
|
|
int |
domain_size | |
|
) |
| | const |
Returns the probability of the given value, for a given domain_size. The domain size determines the probability if the value is unknown, in which case a uniform distribution over all unknown values is assumed.
- Returns:
- The probability of the given value
Definition at line 90 of file PMF.cpp.
double PMF::getProbability |
( |
const std::string & |
value |
) |
const |
Returns the probability of the given value.
- Returns:
- The probability of the given value
Definition at line 86 of file PMF.cpp.
double PMF::getProbabilityUnknown |
( |
int |
domain_size |
) |
const |
double PMF::getProbabilityUnknown |
( |
|
) |
const |
void PMF::getValues |
( |
std::vector< std::string > & |
values |
) |
const |
Returns a vector of values for which a probability is specified.
Definition at line 124 of file PMF.cpp.
PMF & PMF::operator= |
( |
const PMF & |
other |
) |
|
Assignment operator. The operation is cheap since it only copies a pointer. A deep clone will only be created if the original object is modified.
Definition at line 58 of file PMF.cpp.
void PMF::setDomainSize |
( |
int |
domain_size |
) |
|
Sets the domain size of this discrete distribution.
Definition at line 247 of file PMF.cpp.
void PMF::setExact |
( |
const std::string & |
value |
) |
|
Set the probability of the given value to 1. All other values are given a probability of 0.
Definition at line 113 of file PMF.cpp.
void PMF::setProbability |
( |
const std::string & |
value, |
|
|
double |
p | |
|
) |
| | |
Set the probability of a given value.
Definition at line 100 of file PMF.cpp.
std::string PMF::toString |
( |
const std::string & |
indent = "" |
) |
const [virtual] |
Represents the PMF as a string for easier console output.
- Note:
- Should be changed into stream operator <<
- Returns:
- The Gaussian as string
Implements pbl::PDF.
Definition at line 293 of file PMF.cpp.
void PMF::update |
( |
const pbl::PMF & |
other |
) |
|
- Todo:
- : make this implementation more efficient (no need for O(log n) look-ups)
Definition at line 214 of file PMF.cpp.
Member Data Documentation
The documentation for this class was generated from the following files: