aboutsummaryrefslogtreecommitdiffstats
path: root/stratified_sampling.cpp
blob: 98e5442b1cb1dc7c42374ab2ba8950f65338051a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>
#include <gsl/gsl_rng.h>

#include "rtnorm.hpp"
#include <gsl/gsl_cdf.h>


//--génération quantiles--
std::vector<double> quantile_norm(int n, double sigma){
  std::vector<double> q(n);
  for (int i=1; i<n; i++) {
    q[i] = gsl_cdf_gaussian_Pinv ((double)i/n, sigma);
  }
  return q;
}

int main()
{
  //--- GSL random init ---
  gsl_rng_env_setup();                          // Read variable environnement
  const gsl_rng_type* type = gsl_rng_default;   // Default algorithm 'twister'
  gsl_rng *gen = gsl_rng_alloc (type);          // Rand generator allocation
  std::vector<double> q;
  q = quantile_norm(10, 1);
  std::cout<<q[1]<<std::endl;
  return 0;
}