diff options
| author | Bertrand <bertrand.horel@gmail.com> | 2016-02-09 13:49:07 +0000 |
|---|---|---|
| committer | Bertrand <bertrand.horel@gmail.com> | 2016-02-09 13:49:07 +0000 |
| commit | 486c1e061bfe039b0d8baa7cb59cab8f3b8e07ba (patch) | |
| tree | 08a868c13e426c24a554bef61a46d1bf9e8e46a3 | |
| parent | cebf7f9f95653a163511fc95aeb73fbe020e0b46 (diff) | |
| download | projet_C++-486c1e061bfe039b0d8baa7cb59cab8f3b8e07ba.tar.gz | |
ajout fonction estimator
| -rw-r--r-- | stratified_sampling.hpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/stratified_sampling.hpp b/stratified_sampling.hpp index ca96a3c..e9e1823 100644 --- a/stratified_sampling.hpp +++ b/stratified_sampling.hpp @@ -54,7 +54,7 @@ struct stratified_sampling { vector<double> get_mean(); vector<double> get_var(); void print_mean(); - //double estimator(); + pair<double,double> estimator(); private: vector<double> p; vector<int> M; @@ -147,6 +147,19 @@ void stratified_sampling<L>::print_mean() { cout<<mean[i]<<"\t"; } cout<<endl; - } +}; + +template <typename L> +pair<double,double> stratified_sampling<L>::estimator() { + double est_mean; + double est_std; + for (int i=0; i<I; i++) { + est_mean += mean[i]*p[i]; + est_std += sqrt(sigma2[i])*p[i]; + } + return {est_mean, est_std}; +} + + |
