#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_String & | most_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_Litem * | item_start () const |
Used for iterating through members of the distribution. More... | |
EST_Litem * | item_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_String & | item_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_Discrete * | get_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_DiscreteProbDistribution & | operator= (const EST_DiscreteProbDistribution &a) |
Friends | |
ostream & | operator<< (ostream &s, const EST_DiscreteProbDistribution &p) |
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; }
Definition at line 210 of file EST_simplestats.h.
|
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.
|
inline |
Create with given vocabulary.
Definition at line 225 of file EST_simplestats.h.
|
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.
|
inline |
Destructor function.
Definition at line 237 of file EST_simplestats.h.
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.
|
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 |
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.
Used for iterating through members of the distribution.
Definition at line 388 of file EST_DProbDist.cc.
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.
|
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.
|
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.
|
friend |
Definition at line 432 of file EST_DProbDist.cc.