CkSampleT represents a statistical "sample" of some data values. More...
#include <ckstatistics.h>
Public Member Functions | |
CkSampleT (void) | |
void | add (real r) |
Add this value to the sample set. More... | |
void | operator+= (real r) |
Shorthand for add function. More... | |
ret | getMean (void) const |
Return the mean value of this sample–the "average" value, in (value) units. More... | |
ret | getVariance (void) const |
Return the variance of this sample, in (value^2) units. More... | |
ret | getStddev (void) const |
Return the standard deviation of this sample, in (value) units. More... | |
real | getMin (void) const |
Return the smallest value encountered. More... | |
real | getMax (void) const |
Return the largest value encountered. More... | |
int | getCount (void) const |
Return the number of values in this sample. More... | |
void | print (FILE *dest) |
Print a textual description of this sample to this FILE. More... | |
void | printMinAveMax (FILE *dest) |
Print a terse textual description of this sample to this FILE. More... | |
void | print (void) |
Print a textual description of this sample to stdout. More... | |
Private Attributes | |
real | lo |
real | hi |
ret | sum |
ret | sq |
int | n |
CkSampleT represents a statistical "sample" of some data values.
It maintains information it can use to compute means and variances, max and min.
The REAL template parameter is the datatype of the values. The RET template parameter is the datatype of the various accumulators used, and the datatype for the derived parameters.
The CkSample typedef is just CkSampleT<double,double> Other sensible specializations might include CkSampleT<double, long double> for higher precision accumulation, or CkSampleT<int, double> for computing continuous statistics of a discrete distribution.
Definition at line 79 of file ckstatistics.h.
|
inline |
Definition at line 85 of file ckstatistics.h.
References CkSampleT< real, ret >::hi, CkSampleT< real, ret >::lo, CkSampleT< real, ret >::n, CkSampleT< real, ret >::sq, and CkSampleT< real, ret >::sum.
|
inline |
Add this value to the sample set.
This function updates the max, min, and mean and variance for this sample.
Definition at line 95 of file ckstatistics.h.
References CkSampleT< real, ret >::hi, CkSampleT< real, ret >::lo, CkSampleT< real, ret >::n, CkSampleT< real, ret >::sq, and CkSampleT< real, ret >::sum.
Referenced by checkQuality(), and CkSampleT< real, ret >::operator+=().
|
inline |
Return the number of values in this sample.
Definition at line 138 of file ckstatistics.h.
References CkSampleT< real, ret >::n.
Referenced by CkSampleT< real, ret >::print().
|
inline |
Return the largest value encountered.
Definition at line 134 of file ckstatistics.h.
References CkSampleT< real, ret >::hi.
Referenced by CkSampleT< real, ret >::print(), and CkSampleT< real, ret >::printMinAveMax().
|
inline |
Return the mean value of this sample–the "average" value, in (value) units.
Computed as the sum of all values divided by the number of values.
Definition at line 109 of file ckstatistics.h.
References CkSampleT< real, ret >::n, and CkSampleT< real, ret >::sum.
Referenced by CkSampleT< real, ret >::print(), and CkSampleT< real, ret >::printMinAveMax().
|
inline |
Return the smallest value encountered.
Definition at line 130 of file ckstatistics.h.
References CkSampleT< real, ret >::lo.
Referenced by CkSampleT< real, ret >::print(), and CkSampleT< real, ret >::printMinAveMax().
|
inline |
Return the standard deviation of this sample, in (value) units.
Computed as the square root of the variance.
Definition at line 124 of file ckstatistics.h.
References CkSampleT< real, ret >::getVariance(), and sqrt().
Referenced by CkSampleT< real, ret >::print().
|
inline |
Return the variance of this sample, in (value^2) units.
Computed as the sum of the squares of the diffences between each value and the mean, divided by the number of values minus 1.
Definition at line 117 of file ckstatistics.h.
References CkSampleT< real, ret >::n, CkSampleT< real, ret >::sq, and CkSampleT< real, ret >::sum.
Referenced by CkSampleT< real, ret >::getStddev().
|
inline |
Shorthand for add function.
Definition at line 103 of file ckstatistics.h.
References CkSampleT< real, ret >::add().
|
inline |
Print a textual description of this sample to this FILE.
For example, a 1,000,000-value sample of a uniform distribution on [0,1] might give: ave= 0.500367 stddev= 0.288663 min= 1.27012e-06 max= 0.999999 n= 1000000
Definition at line 145 of file ckstatistics.h.
References CkSampleT< real, ret >::getCount(), CkSampleT< real, ret >::getMax(), CkSampleT< real, ret >::getMean(), CkSampleT< real, ret >::getMin(), and CkSampleT< real, ret >::getStddev().
|
inline |
Print a textual description of this sample to stdout.
Definition at line 161 of file ckstatistics.h.
References CkSampleT< real, ret >::print().
Referenced by CkSampleT< real, ret >::print().
|
inline |
Print a terse textual description of this sample to this FILE.
Definition at line 153 of file ckstatistics.h.
References CkSampleT< real, ret >::getMax(), CkSampleT< real, ret >::getMean(), and CkSampleT< real, ret >::getMin().
Referenced by checkQuality().
|
private |
Definition at line 80 of file ckstatistics.h.
Referenced by CkSampleT< real, ret >::add(), CkSampleT< real, ret >::CkSampleT(), and CkSampleT< real, ret >::getMax().
|
private |
Definition at line 80 of file ckstatistics.h.
Referenced by CkSampleT< real, ret >::add(), CkSampleT< real, ret >::CkSampleT(), and CkSampleT< real, ret >::getMin().
|
private |
Definition at line 83 of file ckstatistics.h.
Referenced by CkSampleT< real, ret >::add(), CkSampleT< real, ret >::CkSampleT(), CkSampleT< real, ret >::getCount(), CkSampleT< real, ret >::getMean(), and CkSampleT< real, ret >::getVariance().
|
private |
Definition at line 82 of file ckstatistics.h.
Referenced by CkSampleT< real, ret >::add(), CkSampleT< real, ret >::CkSampleT(), and CkSampleT< real, ret >::getVariance().
|
private |
Definition at line 81 of file ckstatistics.h.
Referenced by CkSampleT< real, ret >::add(), CkSampleT< real, ret >::CkSampleT(), CkSampleT< real, ret >::getMean(), and CkSampleT< real, ret >::getVariance().