40 #ifndef __EST_SIMPLESTATS_H__ 41 #define __EST_SIMPLESTATS_H__ 90 return (((i=(
int*)nametrie.
lookup(n)) !=
NULL) ? *i : p_def_val);
110 {
copy(a);
return *
this; }
124 EST_Discrete &operator [] (
const int t)
const {
return *discretes[t-10];}
146 {n = in; p_sum = isum; p_sumx = isumx;}
151 {n=s.n; p_sum = s.p_sum; p_sumx = s.p_sumx;}
153 void reset(
void) {n = p_sum = p_sumx = 0.0;}
154 void set(
double in,
double isum,
double isumx)
155 {n = in; p_sum = isum; p_sumx = isumx;}
159 double sum() {
return p_sum; }
161 double sumx() {
return p_sumx; }
163 double mean(
void)
const {
return (n==0)?0.0:(p_sum / n); }
166 {
return ((n*p_sumx)-(p_sum*p_sum))/((double)n*(n-1)); }
168 double stddev(
void)
const {
return sqrt(variance()); }
171 { n+=count; p_sum+=a*count; p_sumx+=count*(a*a); }
175 { cumulate(a,1.0);
return *
this;}
178 { cumulate(a,1.0);
return *
this;}
181 {
copy(a);
return *
this;}
233 const double n_samples,
250 double samples(
void)
const {
return num_samples; }
252 void cumulate(
const EST_String &s,
double count=1);
254 void cumulate(
EST_Litem *i,
double count=1);
255 void cumulate(
int i,
double count=1);
261 double entropy(
void)
const;
263 double probability(
const EST_String &s)
const;
265 double probability(
const int i)
const;
269 double frequency(
const int i)
const;
290 void set_frequency(
const EST_String &s,
double c);
294 void set_frequency(
int i,
double c);
295 void set_frequency(
EST_Litem *i,
double c);
298 void override_frequency(
const EST_String &s,
double c);
300 void override_frequency(
int i,
double c);
301 void override_frequency(
EST_Litem *i,
double c);
312 #endif // __EST_SIMPLESTATS_H__ ~EST_DiscreteProbDistribution()
Destructor function.
const EST_Discrete * get_discrete() const
Returns discrete vocabulary of distribution.
EST_Discrete & operator=(const EST_Discrete &a)
double stddev(void) const
standard deviation of currently cummulated values
int name(const EST_String &n) const
An alternative method for getting the int form the name.
double samples(void) const
Total number of example found.
void cumulate(double a, double count=1.0)
double mean(void) const
mean of currently cummulated values
const EST_String & name(const int n) const
The name given the index.
EST_SuffStats(const EST_SuffStats &s)
int index(const EST_String &n) const
int length(void) const
The number of members in the discrete.
void set_num_samples(const double c)
void clear(void)
Delete the tree.
double sumx()
sum of squared values
float max(float a, float b)
INLINE ssize_t length() const
number of items in vector.
friend ostream & operator<<(ostream &s, const EST_Discrete &d)
EST_Discrete & discrete(const int t) const
void copy(const EST_Discrete &d)
EST_Pathname & operator+=(EST_Pathname p, const EST_Pathname addition)
A vector class for double precision floating point numbers. EST_DVector x should be used instead of f...
double variance(void) const
variance of currently cummulated values
EST_Complex operator+(const EST_Complex &z1, const EST_Complex &z2)
bool operator!=(const EST_Discrete &d)
void reset(void)
reset internal values
EST_SuffStats(double in, double isum, double isumx)
double samples(void)
number of samples in set
EST_DiscreteProbDistribution(const EST_Discrete *d)
Create using given EST_Discrete class as the vocabulary.
A string tree index class for indexing arbitrary objects by strings of characters.
double sum()
sum of values
bool init(const EST_StrList &vocab)
(re-)initialise
EST_Discrete(const EST_Discrete &d)
bool operator==(const EST_Discrete &d)
void copy(const EST_SuffStats &s)
EST_String print_to_string(int quote=0)
void def_val(const EST_String &v)
set the default value when a name isn't found (-1 by default)
EST_DiscreteProbDistribution(const EST_TList< EST_String > &vocab)
Create with given vocabulary.
void * lookup(const EST_String &key) const
Find contents index by key, 0 if there is not contents.
EST_DiscreteProbDistribution()