aboutsummaryrefslogtreecommitdiffstats
path: root/stratified_sampling.cpp
diff options
context:
space:
mode:
authorBertrand <bertrand.horel@gmail.com>2016-02-08 14:40:20 +0000
committerBertrand <bertrand.horel@gmail.com>2016-02-08 14:40:20 +0000
commita86b1d918a4c31f74024aa6b42fa0021919585de (patch)
treed8fdea76dabb3fdd04714c413030c290215dc8e5 /stratified_sampling.cpp
parentf339746cc182a746087e3637c9425b1b5f0b0ab2 (diff)
downloadprojet_C++-a86b1d918a4c31f74024aa6b42fa0021919585de.tar.gz
débuggage et seeding
Diffstat (limited to 'stratified_sampling.cpp')
-rw-r--r--stratified_sampling.cpp38
1 files changed, 0 insertions, 38 deletions
diff --git a/stratified_sampling.cpp b/stratified_sampling.cpp
index b959776..c1c8dc1 100644
--- a/stratified_sampling.cpp
+++ b/stratified_sampling.cpp
@@ -1,6 +1,4 @@
#include "stratified_sampling.hpp"
-#include <algorithm>
-#include <iostream>
std::pair<double, double> mean_var( std::vector<double> r){
std::pair<double, double> p;
@@ -13,39 +11,3 @@ std::pair<double, double> mean_var( std::vector<double> r){
p.second -= p.first * p.first;
return p;
}
-
-//actualisation du nombre de tirages à faire par strates
-template <typename Gen>
-void stratified_sampling<Gen>::update(int Nk) {
- int I = p.size();
- //reinitialistation du vecteur M du nombre de tirages par strates
- if (M.empty()) {
- M.resize(I,1);
- }
- else {
- for(int i=0; i<I; i++){
- M[i]=1;
- }
- }
-
- std::vector<double> m(I, 0); //le vecteur des m_i idéals
-
- if (sigma.empty()) {
- for (int i=0; i<I; i++) {
- m[i] = (Nk-I)*p[i];
- }
- }
- else {
- 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;
- }
- }
- M[0]+=floor(m[0]);
- double current = m[0];
- for (int i=1; i<I; i++){
- M[i] += floor(current+m[i]) - floor(current);
- current += m[i];
- }
-}