generic C++ class for maintaining up-to-date mean and variance estimates in constant space
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


samplesink, simple sample data aggregator
Copyright © 2003--2008 William C. Benton

samplesink is a simple generic class for maintaining
aggregate information about a (potentially very large)
collection of samples while using constant space.  It uses
the technique described in "Updating mean and variance
estimates: an improved method" by D.H.D. West, from CACM
22(9); see

It is released under the ASL 2.0 (see LICENSE).
Documentation and unit tests will follow soon; for now,
please see the example code provided in

samplesink is templated on three types:  SampleType,
AggregateType, and CountType.  

* SampleType is the type of your samples, which must be

* AggregateType is the type you want to use for aggregates
(mean, standard deviation), which defaults to double if
left unspecified; and

* CountType is the type you want to use for counts, which
defaults to long if left unspecified.

SampleType can be an arbitrary class if it provides the
basic arithmetic, comparison, and assignment operators and
you create a specialization for the meta::limits class (for
extremes).  AggregateType can be an arbitrary class if you
create a specialization for the support::math class (for a
square-root implementation).  CountType can be an arbitrary
class if it supports the increment operator.