aboutsummaryrefslogtreecommitdiffstats
path: root/stratified_sampling.cpp
blob: c1c8dc121b4056a3355ce0a1c96ca43c17a173c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
#include "stratified_sampling.hpp"

std::pair<double, double> mean_var( std::vector<double> r){
    std::pair<double, double> p;
    for(auto &x: r){
        p.first += x;
        p.second += x*x;
    }
    p.first /= r.size();
    p.second /= r.size();
    p.second -= p.first * p.first;
    return p;
}