$search

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>

Inheritance diagram for pbl::PMF:
Inheritance graph
[legend]

List of all members.

Classes

struct  PMFStruct

Public Member Functions

PMFclone () 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 ()
PMFoperator= (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

PMFStructptr_

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.

PMF::~PMF (  )  [virtual]

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]

Definition at line 79 of file PMF.cpp.

double PMF::getDensity ( const arma::vec v  )  const

Definition at line 283 of file PMF.cpp.

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

Definition at line 160 of file PMF.cpp.

double PMF::getLikelihood ( const PDF pdf  )  const [virtual]

Implements pbl::PDF.

Definition at line 153 of file PMF.cpp.

double PMF::getMaxDensity (  )  const [virtual]

Implements pbl::PDF.

Definition at line 288 of file PMF.cpp.

std::string PMF::getMostProbableValue (  )  const

Definition at line 311 of file PMF.cpp.

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

Definition at line 260 of file PMF.cpp.

double PMF::getProbabilityUnknown (  )  const

Definition at line 256 of file PMF.cpp.

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.

void PMF::normalize (  ) 

Definition at line 267 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

PMFStruct* pbl::PMF::ptr_ [protected]

Definition at line 186 of file PMF.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines


problib
Author(s): Sjoerd van den Dries
autogenerated on Tue Mar 5 12:28:33 2013