Boost logo

Boost Users :

Subject: Re: [Boost-users] [Accumulators] Questions about the library
From: adish (adishavit_at_[hidden])
Date: 2009-06-25 06:41:49


Hi dhruva,

  Thanks for the quick reply.

>  As a user of this library in production software, I will try to answer a few of the queries that I had asked or solved during my development.

Thanks.

>
> >    1. I sometimes need to clear the contents of an accumulator. What is the best way to do this?
>
> Since a pristine or unused accumulator object is quite small (I have not done actual measurements), I just kept 2 variables of the same accumulator type in my C++ wrapper class. I just copied the unused when ever I wanted to reset the accumulator to its original state. One is used for doing all the math and other is used to restore the state.

I see. Thanks.

>
> >    2. If my platform does not support HW floating point ops, and all my
> >    sample values are, e.g. ints, is there a way to specify that the
> > *computation
> >    *and *return value itself* (i.e. result_type, e.g. the mean) will be done
> >    in ints (naturally, at the cost of precision)?
>
> I have used UDT as I needed some extra information from the results (as I was working on data from a time series). The reverse, using a POD like int must be possible. Instead of the first argument being float/double, use an int. If that does not work, you can wrap an int in a UDT, implement some of the operators like '=', '<', '/' depending on the accumulator you plan to use (I did that as I needed to send a UDT).

Using an int still returns a float -- which is quite sensible.

By UDT do you mean User Defined Type?
This is an interesting approach.
I didn't realize that the result_type depends on the value type in
that way, I didn't see any UDTs mentioned in the docs.

>
> >    3. Is there any info about numerical stability of the algorithms used?
> >    For example, there are several
> > waysto
> > calculate the variance, not all being equal.
> >    The same goes for algorithmic efficiency and memory requirements.
>
> No clue on this, I would like to some complexity information so that I can choose or know the computation impact.

Maybe someone else knows.

>
> >    4. On the same note, is there anywhere that explains/describes the actual
> >    algorithms used?
>
> The docs show the formula used to an extent.
>
> >    5. Finally, is there an implementation of a rolling (sliding window)
> >    incremental variance computation?
>
> Check the mean using circular buffer. I had a similar request and the author was kind enough to implement and share it (Thanks Eric for the prompt guiding you did). See under "boost/accumulators/statistics/rolling*" in Boost 1.38+ "include" folder.

Yes, I saw the post and Eric's reply, and the latest ver. 1.39 has
rolling_count, rolling_sum and rolling_mean built in (based, I guess,
on that implementation).
I was wondering if there is a rolling_variance implementation
somewhere.

Thanks,
Adi


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net