Edinburgh Speech Tools  2.1-release
EST_DiscreteProbDistribution Class Reference

#include <include/EST_simplestats.h>

Public Member Functions

 EST_DiscreteProbDistribution ()
 
 EST_DiscreteProbDistribution (const EST_DiscreteProbDistribution &b)
 Create with copying from an existing distribution. More...
 
 EST_DiscreteProbDistribution (const EST_TList< EST_String > &vocab)
 Create with given vocabulary. More...
 
 EST_DiscreteProbDistribution (const EST_Discrete *d)
 Create using given EST_Discrete class as the vocabulary. More...
 
 EST_DiscreteProbDistribution (const EST_Discrete *d, const double n_samples, const EST_DVector &counts)
 
 ~EST_DiscreteProbDistribution ()
 Destructor function. More...
 
void copy (const EST_DiscreteProbDistribution &b)
 Copy all data from another DPD to this. More...
 
void clear (void)
 Reset, clearing all counts and vocabulary. More...
 
bool init (const EST_StrList &vocab)
 Initialise using given vocabulary. More...
 
void init (const EST_Discrete *d)
 Initialise using given EST_Discrete as vocabulary. More...
 
void init ()
 Initialise. More...
 
double samples (void) const
 Total number of example found. More...
 
void cumulate (const EST_String &s, double count=1)
 Add this observation, may specify number of occurrences. More...
 
void cumulate (EST_Litem *i, double count=1)
 Add this observation, i must be with in EST_Discrete range. More...
 
void cumulate (int i, double count=1)
 
const EST_Stringmost_probable (double *prob=NULL) const
 Return the most probable member of the distribution. More...
 
double entropy (void) const
 
double probability (const EST_String &s) const
 
double probability (const int i) const
 
double frequency (const EST_String &s) const
 
double frequency (const int i) const
 
EST_Litemitem_start () const
 Used for iterating through members of the distribution. More...
 
EST_Litemitem_next (EST_Litem *idx) const
 Used for iterating through members of the distribution. More...
 
int item_end (EST_Litem *idx) const
 Used for iterating through members of the distribution. More...
 
const EST_Stringitem_name (EST_Litem *idx) const
 During iteration returns name given index. More...
 
void item_freq (EST_Litem *idx, EST_String &s, double &freq) const
 During iteration returns name and frequency given index. More...
 
void item_prob (EST_Litem *idx, EST_String &s, double &prob) const
 During iteration returns name and probability given index. More...
 
const EST_Discreteget_discrete () const
 Returns discrete vocabulary of distribution. More...
 
void set_frequency (const EST_String &s, double c)
 
void set_frequency (int i, double c)
 
void set_frequency (EST_Litem *i, double c)
 
void override_frequency (const EST_String &s, double c)
 Sets the frequency of named item, without modifying num\_samples. More...
 
void override_frequency (int i, double c)
 Sets the frequency of named item, without modifying num\_samples. More...
 
void override_frequency (EST_Litem *i, double c)
 
void set_num_samples (const double c)
 
EST_DiscreteProbDistributionoperator= (const EST_DiscreteProbDistribution &a)
 

Friends

ostream & operator<< (ostream &s, const EST_DiscreteProbDistribution &p)
 

Detailed Description

A class for representing probability distributions for a set of discrete values.

This may be used to cummulate the probability distribution of a class of values. Values are actually help as frequencies so both frequency and probability information may be available. Note that frequencies are not integers because using smoothing and backoff integers are too restrictive so they are actually represented as doubles.

Methods are provided to iterate over the values in a distribution, for example

   EST_DiscreteProbistribution pdf;
   for (int i=pdf.item_start(); i < pdf.item_end(); i=pdf.item_next(i))
   {
      EST_String name;
      double prob;
      item_prob(i,name,prob);
      std::cout << name << ": prob " << prob << std::endl;
   }
Author
Alan W Black (awb@c.nosp@m.str..nosp@m.ed.ac.nosp@m..uk): July 1996

Definition at line 210 of file EST_simplestats.h.

Constructor & Destructor Documentation

EST_DiscreteProbDistribution::EST_DiscreteProbDistribution ( )
inline

Definition at line 221 of file EST_simplestats.h.

EST_DiscreteProbDistribution::EST_DiscreteProbDistribution ( const EST_DiscreteProbDistribution b)

Create with copying from an existing distribution.

Definition at line 94 of file EST_DProbDist.cc.

EST_DiscreteProbDistribution::EST_DiscreteProbDistribution ( const EST_TList< EST_String > &  vocab)
inline

Create with given vocabulary.

Definition at line 225 of file EST_simplestats.h.

EST_DiscreteProbDistribution::EST_DiscreteProbDistribution ( const EST_Discrete d)
inline

Create using given EST_Discrete class as the vocabulary.

Definition at line 228 of file EST_simplestats.h.

EST_DiscreteProbDistribution::EST_DiscreteProbDistribution ( const EST_Discrete d,
const double  n_samples,
const EST_DVector counts 
)

Create using given EST_Discrete class as vocabulary plus given counts

Definition at line 84 of file EST_DProbDist.cc.

EST_DiscreteProbDistribution::~EST_DiscreteProbDistribution ( )
inline

Destructor function.

Definition at line 237 of file EST_simplestats.h.

Member Function Documentation

void EST_DiscreteProbDistribution::copy ( const EST_DiscreteProbDistribution b)

Copy all data from another DPD to this.

Definition at line 99 of file EST_DProbDist.cc.

void EST_DiscreteProbDistribution::clear ( void  )

Reset, clearing all counts and vocabulary.

Definition at line 108 of file EST_DProbDist.cc.

bool EST_DiscreteProbDistribution::init ( const EST_StrList vocab)

Initialise using given vocabulary.

Definition at line 120 of file EST_DProbDist.cc.

void EST_DiscreteProbDistribution::init ( const EST_Discrete d)

Initialise using given EST_Discrete as vocabulary.

Definition at line 135 of file EST_DProbDist.cc.

void EST_DiscreteProbDistribution::init ( void  )

Initialise.

Definition at line 113 of file EST_DProbDist.cc.

double EST_DiscreteProbDistribution::samples ( void  ) const
inline

Total number of example found.

Definition at line 250 of file EST_simplestats.h.

void EST_DiscreteProbDistribution::cumulate ( const EST_String s,
double  count = 1 
)

Add this observation, may specify number of occurrences.

Definition at line 159 of file EST_DProbDist.cc.

void EST_DiscreteProbDistribution::cumulate ( EST_Litem i,
double  count = 1 
)

Add this observation, i must be with in EST_Discrete range.

Definition at line 147 of file EST_DProbDist.cc.

void EST_DiscreteProbDistribution::cumulate ( int  i,
double  count = 1 
)

Definition at line 153 of file EST_DProbDist.cc.

const EST_String & EST_DiscreteProbDistribution::most_probable ( double *  prob = NULL) const

Return the most probable member of the distribution.

Definition at line 184 of file EST_DProbDist.cc.

double EST_DiscreteProbDistribution::entropy ( void  ) const

Return the entropy of the distribution

\[ -\sum_{i=1}^N(prob(i)*log(prob(i))) \]

Definition at line 341 of file EST_DProbDist.cc.

double EST_DiscreteProbDistribution::probability ( const EST_String s) const

Definition at line 235 of file EST_DProbDist.cc.

double EST_DiscreteProbDistribution::probability ( const int  i) const

Definition at line 243 of file EST_DProbDist.cc.

double EST_DiscreteProbDistribution::frequency ( const EST_String s) const

Definition at line 251 of file EST_DProbDist.cc.

double EST_DiscreteProbDistribution::frequency ( const int  i) const

Definition at line 259 of file EST_DProbDist.cc.

EST_Litem * EST_DiscreteProbDistribution::item_start ( void  ) const

Used for iterating through members of the distribution.

Definition at line 372 of file EST_DProbDist.cc.

EST_Litem * EST_DiscreteProbDistribution::item_next ( EST_Litem idx) const

Used for iterating through members of the distribution.

Definition at line 388 of file EST_DProbDist.cc.

int EST_DiscreteProbDistribution::item_end ( EST_Litem idx) const

Used for iterating through members of the distribution.

Definition at line 380 of file EST_DProbDist.cc.

const EST_String & EST_DiscreteProbDistribution::item_name ( EST_Litem idx) const

During iteration returns name given index.

Definition at line 396 of file EST_DProbDist.cc.

void EST_DiscreteProbDistribution::item_freq ( EST_Litem idx,
EST_String s,
double &  freq 
) const

During iteration returns name and frequency given index.

Definition at line 404 of file EST_DProbDist.cc.

void EST_DiscreteProbDistribution::item_prob ( EST_Litem idx,
EST_String s,
double &  prob 
) const

During iteration returns name and probability given index.

Definition at line 418 of file EST_DProbDist.cc.

const EST_Discrete* EST_DiscreteProbDistribution::get_discrete ( ) const
inline

Returns discrete vocabulary of distribution.

Definition at line 285 of file EST_simplestats.h.

void EST_DiscreteProbDistribution::set_frequency ( const EST_String s,
double  c 
)

Sets the frequency of named item, modifies num\_samples accordingly. This is used when smoothing frequencies.

Definition at line 270 of file EST_DProbDist.cc.

void EST_DiscreteProbDistribution::set_frequency ( int  i,
double  c 
)

Sets the frequency of named item, modifies num\_samples accordingly. This is used when smoothing frequencies.

Definition at line 286 of file EST_DProbDist.cc.

void EST_DiscreteProbDistribution::set_frequency ( EST_Litem i,
double  c 
)

Definition at line 301 of file EST_DProbDist.cc.

void EST_DiscreteProbDistribution::override_frequency ( const EST_String s,
double  c 
)

Sets the frequency of named item, without modifying num\_samples.

Definition at line 317 of file EST_DProbDist.cc.

void EST_DiscreteProbDistribution::override_frequency ( int  i,
double  c 
)

Sets the frequency of named item, without modifying num\_samples.

Definition at line 325 of file EST_DProbDist.cc.

void EST_DiscreteProbDistribution::override_frequency ( EST_Litem i,
double  c 
)

Definition at line 333 of file EST_DProbDist.cc.

void EST_DiscreteProbDistribution::set_num_samples ( const double  c)
inline

Sets the number of samples. Care should be taken on setting this as it will affect how probabilities are calculated.

Definition at line 306 of file EST_simplestats.h.

EST_DiscreteProbDistribution & EST_DiscreteProbDistribution::operator= ( const EST_DiscreteProbDistribution a)

Definition at line 452 of file EST_DProbDist.cc.

Friends And Related Function Documentation

ostream& operator<< ( ostream &  s,
const EST_DiscreteProbDistribution p 
)
friend

Definition at line 432 of file EST_DProbDist.cc.


The documentation for this class was generated from the following files: