diff options
| author | Bertrand <bertrand.horel@gmail.com> | 2016-02-13 17:45:17 +0000 |
|---|---|---|
| committer | Bertrand <bertrand.horel@gmail.com> | 2016-02-13 17:45:17 +0000 |
| commit | 9f7ae751a0d6f7d27ad5f19d4fc697e722286b39 (patch) | |
| tree | 4b7e92a3d341c76b3714dc80addf01da028a96f4 | |
| parent | fc58c91b6a87c93ccb0a5fba025cf223716d0f5b (diff) | |
| download | projet_C++-9f7ae751a0d6f7d27ad5f19d4fc697e722286b39.tar.gz | |
Ajout de update dans la fonction draw
| -rw-r--r-- | main.cpp | 12 | ||||
| m--------- | qmc | 0 | ||||
| -rw-r--r-- | stratified_sampling.hpp | 7 | ||||
| -rw-r--r-- | stratified_sampling.hpp.gch | bin | 0 -> 42958160 bytes |
4 files changed, 10 insertions, 9 deletions
@@ -29,18 +29,18 @@ int main() rvar.push_back(gaussian_truncated(q[i-1], q[i],0,1,i)); } stratified_sampling<gaussian_truncated> S(p,rvar); - S.update(100); - S.draw(); + //S.update(100); + S.draw(100); double x = 1.64*S.estimator().second; cout<<"l'estimateur de la moyenne est :"<<S.estimator().first<<endl; cout<<"Son intervalle de confiance à 95% est :"<<"["<<S.estimator().first-(x/10)<<" ,"<<S.estimator().first+(x/10)<<"]"<<endl; - S.update(1000); - S.draw(); + //S.update(1000); + S.draw(1000); x = 1,64*S.estimator().second; cout<<"l'estimateur de la moyenne est :"<<S.estimator().first<<endl; cout<<"Son intervalle de confiance à 95% est :"<<"["<<S.estimator().first-(x/sqrt(1100))<<" ,"<<S.estimator().first+(x/sqrt(1100))<<"]"<<endl; - S.update(10000); - S.draw(); + //S.update(10000); + S.draw(10000); x = 1,64*S.estimator().second; cout<<"l'estimateur de la moyenne est :"<<S.estimator().first<<endl; cout<<"Son intervalle de confiance à 95% est :"<<"["<<S.estimator().first-(x/sqrt(11100))<<" ,"<<S.estimator().first+(x/sqrt(11100))<<"]"<<endl; diff --git a/qmc b/qmc -Subproject 0b1bd7f4c4184cb3cf52aa227698fed5d3cb5ee +Subproject 3723be5c65f44ae0d9ea25a9e563163e3e1b044 diff --git a/stratified_sampling.hpp b/stratified_sampling.hpp index e7b3978..81080fc 100644 --- a/stratified_sampling.hpp +++ b/stratified_sampling.hpp @@ -49,14 +49,14 @@ template <typename L> struct stratified_sampling { stratified_sampling(vector<double> p, vector<L> X) :p(p), X(X), mean(p.size(), 0), sigma2(p.size(), 0), I(p.size()){}; - void update(int N); - void draw(); + void draw(int N); vector<double> get_mean() const; vector<double> get_var() const; void print_mean() const; void print_sigma() const; pair<double,double> estimator() const; private: + void update(int N); vector<double> p; vector<L> X; vector<int> M; @@ -111,7 +111,8 @@ void stratified_sampling<L>::update(int Nk) { } template <typename L> -void stratified_sampling<L>::draw() { +void stratified_sampling<L>::draw(int N) { + update(N); double m, s, oldmean; for(int i=0;i<I;i++){ m=0; diff --git a/stratified_sampling.hpp.gch b/stratified_sampling.hpp.gch Binary files differnew file mode 100644 index 0000000..3d6986e --- /dev/null +++ b/stratified_sampling.hpp.gch |
