From 8b3d7e86b167f31fa730e953a0de41c6bd978668 Mon Sep 17 00:00:00 2001 From: Bertrand Date: Tue, 9 Feb 2016 13:30:18 +0000 Subject: qques changements de style --- stratified_sampling.hpp | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) (limited to 'stratified_sampling.hpp') diff --git a/stratified_sampling.hpp b/stratified_sampling.hpp index e25ac63..21bfea8 100644 --- a/stratified_sampling.hpp +++ b/stratified_sampling.hpp @@ -45,13 +45,14 @@ private: gsl_rng *gen; }; -template +template struct stratified_sampling { - stratified_sampling(vector p, vector gen) - :p(p), gen(gen), mean(p.size(), 0), sigma2(p.size(), 0){}; + stratified_sampling(vector p, vector X) + :p(p), X(X), mean(p.size(), 0), sigma2(p.size(), 0), I(p.size()){}; void update(int N); void draw(); vector get_mean(); + vector get_var(); //double estimator(); private: vector p; @@ -59,14 +60,13 @@ private: vector cumM; vector mean; vector sigma2; - vector gen; - + vector X; + int I; }; //actualisation du nombre de tirages à faire par strates -template -void stratified_sampling::update(int Nk) { - int I = p.size(); +template +void stratified_sampling::update(int Nk) { bool first_step = M.empty(); //reinitialistation du vecteur M du nombre de tirages par strates if (first_step) { @@ -99,26 +99,30 @@ void stratified_sampling::update(int Nk) { std::cout< -void stratified_sampling::draw() { - int I = p.size(); +template +void stratified_sampling::draw() { double m, s, oldmean; for(int i=0;i::draw() { } }; -template -vector stratified_sampling::get_mean() { +template +vector stratified_sampling::get_mean() { return mean; }; + +template +vector stratified_sampling::get_var() { + return sigma2; +}; + -- cgit v1.2.3-70-g09d2