diff options
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | stratified_sampling.cpp | 6 |
2 files changed, 4 insertions, 4 deletions
@@ -1,7 +1,7 @@ CXX=g++ CC=gcc RM = rm -CXXFLAGS=-O3 +CXXFLAGS=-std=c++11 -O3 GSL_FLAGS:=$(shell pkg-config --libs gsl) stratified_sampling: rtnorm.o stratified_sampling.o diff --git a/stratified_sampling.cpp b/stratified_sampling.cpp index 22bdbf5..f6c3ff1 100644 --- a/stratified_sampling.cpp +++ b/stratified_sampling.cpp @@ -26,9 +26,9 @@ double quantile_truncate_normal (int i, int n, double mu, std::pair<double, double> mean_var( std::vector<double> r){ std::pair<double, double> p; - for(int i=0; i<r.size(); i++){ - p.first += r[i]; - p.second += r[i]*r[i]; + for(auto &x: r){ + p.first += x; + p.second += x*x; } p.first /= r.size(); p.second /= r.size(); |
