diff options
Diffstat (limited to 'src/stratified_sampling.hpp')
| -rw-r--r-- | src/stratified_sampling.hpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/stratified_sampling.hpp b/src/stratified_sampling.hpp index 7573ef2..c04369e 100644 --- a/src/stratified_sampling.hpp +++ b/src/stratified_sampling.hpp @@ -141,8 +141,9 @@ void stratified_sampling<L>::draw(int N) { m=0; s=0; for(int j=0;j<M[i];j++){ - m=m+X[i](); - s=s+X[i].current()*X[i].current(); + double temp = X[i](); + m=m+temp; + s=s+temp*temp; } oldmean=mean[i]; mean[i]=(mean[i]*cumM[i]+m)/(cumM[i]+M[i]); @@ -192,8 +193,8 @@ pair<double,double> stratified_sampling<L>::estimator() const { struct f_mu : public std::unary_function<std::vector<double>, double> { f_mu(std::vector<double> mu, asian_option A) : mu(mu), A(A){ - double norm_mu = 0; - for(int i=0; i<16; i++) { + norm_mu = 0; + for(unsigned int i=0; i<mu.size(); i++) { norm_mu += mu[i]*mu[i]; } }; |
