blob: c1eb3ecc49c9dadfce256d07ce21b352fa93ba2c (
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
29
30
31
32
33
34
35
|
#include <iostream>
#include <gsl/gsl_rng.h>
#include <vector>
//#include "rtnorm.hpp"
#include <gsl/gsl_cdf.h>
#include <gsl/gsl_math.h>
#include "stratified_sampling.hpp"
#include <cmath>
#include <algorithm>
//--génération quantiles--
std::vector<double> quantile_norm(int n, double sigma){
std::vector<double> q(n);
for (int i=0; i<n; i++) {
q[i] = gsl_cdf_gaussian_Pinv ((double)(i+1)/n, sigma);
}
return q;
}
int main()
{
//--- GSL random init ---
gsl_rng_env_setup();
std::vector<double> q;
q = quantile_norm(10, 1);
vector<double> p(10, 0.1);
vector<gaussian_truncated> gen;
gen.push_back(gaussian_truncated(GSL_NEGINF,q[0]));
for (int i=1; i<10; i++){
gen.push_back(gaussian_truncated(q[i-1],q[i]));
}
stratified_sampling<gaussian_truncated> S(p, gen);
//S.update(1000);
return 0;
}
|