#include <include/EST_simplestats.h>
Public Member Functions | |
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) | |
~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_Discrete} 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 occurrences. | |
void | cumulate (EST_Litem *i, double count=1) |
Add this observation, i must be with in EST_Discrete range. | |
void | cumulate (int i, double count=1) |
const EST_String & | most_probable (double *prob=NULL) const |
Return the most probable member of the distribution. | |
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. | |
EST_Litem * | item_next (EST_Litem *idx) const |
Used for iterating through members of the distribution. | |
int | item_end (EST_Litem *idx) const |
Used for iterating through members of the distribution. | |
const EST_String & | item_name (EST_Litem *idx) const |
During iteration returns name given index. | |
void | item_freq (EST_Litem *idx, EST_String &s, double &freq) const |
During iteration returns name and frequency given index. | |
void | item_prob (EST_Litem *idx, EST_String &s, double &prob) const |
During iteration returns name and probability given index. | |
const EST_Discrete *const | get_discrete () const |
Returns discrete vocabulary of distribution. | |
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}. | |
void | override_frequency (int i, double c) |
Sets the frequency of named item, without modifying { num_samples}. | |
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 {verbatim} 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; } {verbatim}
Definition at line 210 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 82 of file EST_DProbDist.cc.
double EST_DiscreteProbDistribution::entropy | ( | void | ) | const |
Return the entropy of the distribution [ -{i=1}^N(prob(i)*log(prob(i))) ]
Definition at line 339 of file EST_DProbDist.cc.
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 268 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 284 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.