|
Boost Users : |
Subject: [Boost-users] Variance calcs in the stats library and in Excel
From: Archie14 (admin_at_[hidden])
Date: 2009-07-22 08:07:38
In the docs
(file:///C:/Libraries/boost/boost_1_39_0/doc/html/accumulators/user_s_guide.htm
l#accumulators.user_s_guide.the_statistical_accumulators_library.variance)
there is an example of calculating variance of values 1,2,3,4,5
accumulator_set<int, stats<tag::variance(lazy)> > acc1;
acc1(1);
acc1(2);
acc1(3);
acc1(4);
acc1(5);
BOOST_CHECK_EQUAL(5u, count(acc1));
BOOST_CHECK_CLOSE(3., mean(acc1), 1e-5);
BOOST_CHECK_CLOSE(11., moment<2>(acc1), 1e-5);
BOOST_CHECK_CLOSE(2., variance(acc1), 1e-5);
When I am doing the same in Excel the mean is indeed 3, which matches the
example, but variance is 2.5 and not 2. I am using AVERAGE and VAR formulas in
Excel for mean and variance respectively
Why there is a mismatch between variance values??
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