diff options
| author | Bertrand <bertrand.horel@gmail.com> | 2016-02-09 14:48:21 +0000 |
|---|---|---|
| committer | Bertrand <bertrand.horel@gmail.com> | 2016-02-09 14:48:21 +0000 |
| commit | 861100a098452ddd02a9df1cf58ec8ea8fadf07f (patch) | |
| tree | cf665c94dc745ee97dde1da64c12bfe4b70a0f1c /stratified_sampling.hpp | |
| parent | 486c1e061bfe039b0d8baa7cb59cab8f3b8e07ba (diff) | |
| download | projet_C++-861100a098452ddd02a9df1cf58ec8ea8fadf07f.tar.gz | |
estimateur, intervalles de confiances ...
Diffstat (limited to 'stratified_sampling.hpp')
| -rw-r--r-- | stratified_sampling.hpp | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/stratified_sampling.hpp b/stratified_sampling.hpp index e9e1823..cf857ec 100644 --- a/stratified_sampling.hpp +++ b/stratified_sampling.hpp @@ -54,6 +54,7 @@ struct stratified_sampling { vector<double> get_mean(); vector<double> get_var(); void print_mean(); + void print_sigma(); pair<double,double> estimator(); private: vector<double> p; @@ -97,22 +98,16 @@ void stratified_sampling<L>::update(int Nk) { double scal = std::inner_product(p.begin(), p.end(), sigma.begin(), (double) 0); for (int i=0; i < I; i++) { m[i] = (Nk-I)*p[i]*sigma[i]/scal; - std::cout<<m[i]<<std::endl; + //std::cout<<m[i]<<std::endl; } } - std::cout<<"M[O] avant mis à jour"<<M[0]<<endl; M[0]+=floor(m[0]); - std::cout<<"M[0] après"<<M[0]<<endl; double current = m[0]; - int compteur = M[0]; - for (int i=1; i<I; i++){ + for (int i=1; i<I-1; i++){ M[i] += floor(current+m[i]) - floor(current); current += m[i]; - compteur += M[i]; - cout<<M[i]<<"\t"; } - cout<<endl; - cout<<compteur<<endl; + M[I-1]+=Nk-I-floor(current); } template <typename L> @@ -143,16 +138,26 @@ vector<double> stratified_sampling<L>::get_var() { template <typename L> void stratified_sampling<L>::print_mean() { - for(int i=0;i<10;i++){ + cout<<"les espérances :"<<endl; + for(int i=0;i<I;i++){ cout<<mean[i]<<"\t"; } cout<<endl; }; template <typename L> +void stratified_sampling<L>::print_sigma() { + cout<<"les écarts types :"<<endl; + for(int i=0;i<I;i++){ + cout<<sqrt(sigma2[i])<<"\t"; + } + cout<<endl; +}; + +template <typename L> pair<double,double> stratified_sampling<L>::estimator() { - double est_mean; - double est_std; + double est_mean = 0; + double est_std = 0; for (int i=0; i<I; i++) { est_mean += mean[i]*p[i]; est_std += sqrt(sigma2[i])*p[i]; |
