Boost logo

Boost Users :

Subject: Re: [Boost-users] [Accumulators] Are all statistics lazily evaluated by default?
From: Eric Niebler (eric_at_[hidden])
Date: 2009-05-11 20:59:05

pete_at_[hidden] wrote:
> Hi all,
> I really like the range of statistical properties that the accumulators
> library supports but am a little unclear about the laziness properties
> of the library.
> Suppose I wish to offer a interface that lets the user send a bunch of
> data and request the k-th moments where k is specified by the user at
> runtime. Will the accumulator_set
> accumulator_set< value_type , ba::tag::moments<k_max> > acc;
> where k_max >= k (but the inequality may be strict) be efficient. I.e. I
> only do the calculations necessary to get the k-th moment not the
> k-max-th? The reason I ask is the documentation makes a distinction
> between variance and lazy_variance, but this distinction does not seem
> to be made for other statistics.


The accumulators library doesn't mandate laziness or eagerness. As
you've noticed, some accumulators come in lazy or eager flavors. Each
accumulator defines an operator() that accepts a sample and a result()
function that extracts the result. Whether the bulk of the work gets
done in operator() (eager) or in result() (lazy) is up to you.


Eric Niebler
BoostPro Computing

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at