For one you were not including the header for kurtosis
:
#include <boost/accumulators/statistics/kurtosis.hpp>
Even if you did, as you see it does not work with a straight vector
, what you probably want to do is use an accumulator_set
and more headers as well.
Here is a minimal example using accumulator_set
, this shows a two methods to solve the problem:
#include <boost/math/distributions.hpp>
#include <boost/accumulators/accumulators.hpp>
#include <boost/accumulators/statistics/stats.hpp>
#include <boost/accumulators/statistics/mean.hpp>
#include <boost/accumulators/statistics/variance.hpp>
#include <boost/accumulators/statistics/kurtosis.hpp>
#include <iostream>
#include <vector>
using namespace boost::accumulators;
int main()
{
accumulator_set<double, stats<tag::mean, tag::kurtosis > > acc;
accumulator_set<double, stats<tag::mean, tag::kurtosis > > acc2;
acc(2) ;
acc(3) ;
acc(4) ;
std::cout << mean(acc) << " " << kurtosis(acc) << std::endl ;
std::vector<double> v1 ;
v1.push_back(2);
v1.push_back(3);
v1.push_back(4);
acc2 = std::for_each( v1.begin(), v1.end(), acc2 ) ;
std::cout << mean(acc2) << " " << kurtosis(acc2) << std::endl ;
}
Here is a link to the Accumulators Framework
User's Guide. This guide has some nice examples.
This previous thread found a way to use vector
, although it is not straight forward at all and I could not get it work.