aboutsummaryrefslogtreecommitdiffstats
path: root/src/stratified_sampling.cpp
blob: 156751f78676619c7e54ff55886dd577413765ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#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;
}