samp.h provides components for taking sample statistics. Functions are provided for computing mean, standard deviation, etc. based on data obtained by unspecified means. This represents the lowest level of sample statistics provided. Concrete data types are provided for computing sample statistics from raw data. The data are fed to the object one sample at a time using operator(). These objects have the random variable type (DRAND or CRAND) as a template parameter. The supported statistics include:
Convenience functions are provided to convert a sorted array of samples to other statistics such as the empirical cumulative distribution function.
Polymorphic interfaces IDiSamp and ICoSamp are provided for discrete and continuous random variables. Many combinations of the statistics above are supported. DiHistogram and CoHistogram are additionally derived from IDiDist and ICoDist so that you can treat empirically derived distributions in the same way you treat theoretical distributions.
| UVS Name | Mathematical Operation |
|---|---|
| sample_min | min[xj], j = 0..n-1 |
| sample_max | max[xj], j = 0..n-1 |
| sample_count | n |
| sample_sum_x1 | sum[xj], j = 0..n-1 |
| sample_sum_xma1 | sum[xj-a], j = 0..n-1 |
| sample_sum_x2 | sum[xj^2], j = 0..n-1 |
| sample_sum_xma2 | sum[(xj-a)^2], j = 0..n-1 |
| sample_array | {x0 < x1 < ... < xn-1} |
| UVS Name | Composition |
|---|---|
| sample_range | sample_min + sample_max |
| sample_mean | sample_count + sample_sum_x1 |
| sample_stdev | sample_mean + sample_sum_x2 |
| sample_summary | sample_stdev + sample_range |
| sample_histogram | sample_summary + sample_array |
IDiDist IDiSamp ICoDist ICoSamp <--abstract interface
| | | |
| DiCount | CoCount <--just counts the samples
| | | |
| DiMean | CoMean <--as above plus mean
| | | |
| DiStdev | CoStdev <--as above plus variance and standard deviation
| | | |
| DiSummary | CoSummary <--as above plus min and max
| | | |
----- ----- ----- -----
| | | |
DiHistogram CoHistogram <--as above plus sorted array of the samples
Note that DiHistogram and CoHistogram are also distributions so you have access to such things as empirically determined cumulative distribution functions.
Functions are provided to print most of these classes to an output stream. For concrete types this is done with a function named "display" which takes an output stream and the concrete sample statistic as arguments. For polymorphic types a member function called "show" which takes an output stream as its argument performs the same function.
In C++ standard library terms a sample statistic can be thought of as an output iterator. UVS supports this notion with class samp_output_iterator<SAMP> where "SAMP" is one of the sample statistic classed above. There is a convenience function called samp_output which can be used as follows:
#include <iostream> // for std::cout #include <vector> // for std::vector #include <algorithm> // for std::copy #include "uvs/samp.h" // for uvs::DiHistogram and uvs::samp_output std::vector<int> my_vec; [store values in my_vec] uvs::DiHistogram h; std::copy(my_vec.begin(), my_vec.end(), uvs::samp_output(h)); h.show(std::cout);
This will display a histogram of the values stored in my_vec.