From 3711294a9ca5b6651b6486eb1fe053ff697528ec Mon Sep 17 00:00:00 2001 From: Bertrand Date: Wed, 3 Feb 2016 21:00:07 +0000 Subject: fonction d'update du nombres de tirages par strates --- stratified_sampling.cpp | 54 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 3 deletions(-) (limited to 'stratified_sampling.cpp') diff --git a/stratified_sampling.cpp b/stratified_sampling.cpp index f6c3ff1..4703aba 100644 --- a/stratified_sampling.cpp +++ b/stratified_sampling.cpp @@ -1,9 +1,16 @@ #include #include - +#include #include "rtnorm.hpp" #include #include +#define LOW_DISCREPANCY_HPP +#include +#include +#include +#include +#include + //--génération quantiles-- std::vector quantile_norm(int n, double sigma){ @@ -35,6 +42,37 @@ std::pair mean_var( std::vector r){ p.second -= p.first * p.first; return p; } +//actualisation du nombre de tirages à faire par strates +std::vector update_sampling (std::vector p, +std::vector sigma, int n) { + std::vector r; // notre vecteur final à retourner + std::vector m; //le vecteur des Mi idéals + int s = p.size(); + if (sigma.empty()) { + for (int i = 0; i q; q = quantile_norm(10, 1); - std::cout< p; std::pair mv; @@ -65,8 +103,18 @@ int main() r[j] = p.first; } mv = mean_var(r); - std::cout<<"mean :"< k; + std::vector z = {(double)1/3,(double)1/3,(double)1/3}; + std::vector sigma = {0.1, 0.4, 0.3}; + k = update_sampling(z, sigma, 10000); + for (int j=0; j