In file ../include/EST_simplestats.h:

class EST_DiscreteProbDistribution

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

Public Methods

[more] 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)
Create using given EST_Discrete class as vocabulary plus given counts
[more] ~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_Distcrete 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 occurences
[more]void cumulate (const int i, double count=1)
Add this observation, i must be with in EST_Discrete range
[more]const EST_String& most_probable (double* prob = NULL) const
Return the most probable member of the distribution
[more]double entropy (void) const
Return the entropy of the distribution

[more]double probability (const EST_String &s) const
[more]double probability (const int i) const
[more]double frequency (const EST_String &s) const
[more]double frequency (const int i) const
[more]int item_start () const
Used for iterating through members of the distribution
[more]int item_next (int idx) const
Used for iterating through members of the distribution
[more]int item_end (int idx) const
Used for iterating through members of the distribution
[more]const EST_String& item_name (int idx) const
During iteration ruturns name given index
[more]void item_freq (int idx, EST_String &s, double &freq) const
During iteration ruturns name and frequency given index
[more]void item_prob (int idx, EST_String &s, double &prob) const
During iteration ruturns name and probability given index
[more]inline const EST_Discrete* const get_discrete () const
Returns discrete vocabilary of distribution
[more]void set_frequency (const EST_String &s, double c)
Sets the frequency of named item, modifes num_samples accordingly.
[more]void set_frequency (int i, double c)
Sets the frequency of named item, modifes num_samples accordingly.
[more]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 set_num_samples (const double c)
Sets the number of samples.


Documentation

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 usings 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);
          cout << name << ": prob " << prob << endl;
       }
    

o EST_DiscreteProbDistribution(const EST_DiscreteProbDistribution &b)
Create with copying from an existing distribution

o EST_DiscreteProbDistribution(const EST_TList<EST_String> &vocab)
Create with given vocabulary

o EST_DiscreteProbDistribution(const EST_Discrete* d)
Create using given EST_Discrete class as the vocabulary

o 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

o ~EST_DiscreteProbDistribution()
Destructor function

ovoid copy(const EST_DiscreteProbDistribution &b)
Copy all data from another DPD to this

ovoid clear(void)
Reset, clearing all counts and vocabulary

obool init(const EST_StrList &vocab)
Initialise using given vocabulary

ovoid init(const EST_Discrete* d)
Initialise using given EST_Distcrete as vocabulary

ovoid init()
Initialise

odouble samples(void) const
Total number of example found

ovoid cumulate(const EST_String &s, double count=1)
Add this observation, may specify number of occurences

ovoid cumulate(const int i, double count=1)
Add this observation, i must be with in EST_Discrete range

oconst EST_String& most_probable(double* prob = NULL) const
Return the most probable member of the distribution

odouble entropy(void) const
Return the entropy of the distribution

odouble probability(const EST_String &s) const

odouble probability(const int i) const

odouble frequency(const EST_String &s) const

odouble frequency(const int i) const

oint item_start() const
Used for iterating through members of the distribution

oint item_next(int idx) const
Used for iterating through members of the distribution

oint item_end(int idx) const
Used for iterating through members of the distribution

oconst EST_String& item_name(int idx) const
During iteration ruturns name given index

ovoid item_freq(int idx, EST_String &s, double &freq) const
During iteration ruturns name and frequency given index

ovoid item_prob(int idx, EST_String &s, double &prob) const
During iteration ruturns name and probability given index

oinline const EST_Discrete* const get_discrete() const
Returns discrete vocabilary of distribution

ovoid set_frequency(const EST_String &s, double c)
Sets the frequency of named item, modifes num_samples accordingly. This is used when smoothing frequencies.

ovoid set_frequency(int i, double c)
Sets the frequency of named item, modifes num_samples accordingly. This is used when smoothing frequencies.

ovoid override_frequency(const EST_String &s, double c)
Sets the frequency of named item, without modifying num_samples

ovoid override_frequency(int i, double c)
Sets the frequency of named item, without modifying num_samples

ovoid set_num_samples(const double c)
Sets the number of samples. Care should be taken on setting this as it will affect how probabilities are calculated.


This class has no child classes.
Friends:
ostream & operator <<(ostream &s, const EST_DiscreteProbDistribution &p)
Author:
Alan W Black (awb@cstr.ed.ac.uk): July 1996

Alphabetic index HTML hierarchy of classes or Java


This page is part of the Edinburgh Speech Tools Library documentation
Copyright University of Edinburgh 1997
Contact: speech_tools@cstr.ed.ac.uk