In file ../include/EST_simplestats.h:

## class EST_DiscreteProbDistribution

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

### Public Methods

  | EST_DiscreteProbDistribution (const EST_DiscreteProbDistribution &b) Create with copying from an existing distribution
  | EST_DiscreteProbDistribution (const EST_TList<EST_String> &vocab) Create with given vocabulary
  | EST_DiscreteProbDistribution (const EST_Discrete* d) Create using given EST_Discrete class as the vocabulary
  | 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
  | ~EST_DiscreteProbDistribution () Destructor function
  void | copy (const EST_DiscreteProbDistribution &b) Copy all data from another DPD to this
  void | clear (void) Reset, clearing all counts and vocabulary
  bool | init (const EST_StrList &vocab) Initialise using given vocabulary
  void | init (const EST_Discrete* d) Initialise using given EST_Distcrete as vocabulary
  void | init () Initialise
  double | samples (void) const Total number of example found
  void | cumulate (const EST_String &s, double count=1) Add this observation, may specify number of occurences
  void | cumulate (const int i, double count=1) Add this observation, i must be with in EST_Discrete range
  const EST_String& | most_probable (double* prob = NULL) const Return the most probable member of the distribution
  double | entropy (void) const Return the entropy of the distribution
  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
  int | item_start () const Used for iterating through members of the distribution
  int | item_next (int idx) const Used for iterating through members of the distribution
  int | item_end (int idx) const Used for iterating through members of the distribution
  const EST_String& | item_name (int idx) const During iteration ruturns name given index
  void | item_freq (int idx, EST_String &s, double &freq) const During iteration ruturns name and frequency given index
  void | item_prob (int idx, EST_String &s, double &prob) const During iteration ruturns name and probability given index
  inline const EST_Discrete* const | get_discrete () const Returns discrete vocabilary of distribution
  void | set_frequency (const EST_String &s, double c) Sets the frequency of named item, modifes `num_samples` accordingly.
  void | set_frequency (int i, double c) Sets the frequency of named item, modifes `num_samples` accordingly.
  void | override_frequency (const EST_String &s, double c) Sets the frequency of named item, without modifying `num_samples`
  void | override_frequency (int i, double c) Sets the frequency of named item, without modifying `num_samples`
  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;
>            }

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

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

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

`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

`~EST_DiscreteProbDistribution()`
  Destructor function

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

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

`bool init(const EST_StrList &vocab)`
  Initialise using given vocabulary

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

`void init()`
  Initialise

`double samples(void) const`
  Total number of example found

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

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

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

`double entropy(void) const`
  Return the entropy of the distribution

`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`

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

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

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

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

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

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

`inline const EST_Discrete* const get_discrete() const`
  Returns discrete vocabilary of distribution

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

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

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

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

`void 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