Boost logo

Boost Users :

Subject: Re: [Boost-users] boost::math::standard_deviation how to use ?
From: Edouard Tallent (tallent_e_at_[hidden])
Date: 2012-08-18 13:53:04


My 2-cent
One can easily compute the standard deviation of data contained in a std::vector as shown here:
http://stackoverflow.com/questions/7616511/calculate-mean-and-standard-deviation-from-a-vector-of-samples-in-c-using-boost
Another option is resorting on boost, and any boost container as here:
http://www.boost.org/doc/libs/1_41_0/libs/math/doc/sf_and_dist/html/math_toolkit/dist/stat_tut/weg/find_eg/find_mean_and_sd_eg.html
I mean I am not sure ** in this case *** trying to mix standard vector and boost is the best solution.
Best
Edouard

https://quantcorner.wordpress.com/

=========

Message: 4
Date: Fri, 17 Aug 2012 13:15:50 -0700 (PDT)
From: leeto <denisigoshev_at_[hidden]>
To: boost-users_at_[hidden]
Subject: [Boost-users] boost::math::standard_deviation how to use ?
Message-ID: <1345234550791-4634435.post_at_[hidden]>
Content-Type: text/plain; charset=us-ascii

How to compute standard_deviation using boost
I want that interface will be like in excel i mean you mark some data and
that all )
How do the same in c++ boost using data from a standard container like
vector for example...
Many thanks in advance

#include <boost/math/distributions.hpp> // For non-member functions of
distributions
#include <vector>

#include <numeric>

using namespace std;

int main ()
{

std::vector<double> v;
for (unsigned int i = 0; i < 7; i++)
{
v.push_back(std::rand()%7);
}

std::vector<double>::iterator i = v.begin();

for (i ; i != v.end(); ++i)
{
std::cout << (*i) << ", ";
}

cout << std::accumulate(v.begin(), v.end(),0) << endl;

//boost::math::normal_distribution

cout << "\n\n\n" ;
return 0;


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