From 1af6715ddc3e3fb48eee3846d55979a77890ecec Mon Sep 17 00:00:00 2001 From: nojhan Date: Wed, 9 Nov 2011 11:38:40 +0100 Subject: [PATCH] BUGFIX: should use the standard deviation when sampling a mono-normal law, because it have the same scale than the mean --- edo/src/edoSamplerNormalMono.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/edo/src/edoSamplerNormalMono.h b/edo/src/edoSamplerNormalMono.h index b3162f92f..b9340b179 100644 --- a/edo/src/edoSamplerNormalMono.h +++ b/edo/src/edoSamplerNormalMono.h @@ -28,6 +28,8 @@ Authors: #ifndef _edoSamplerNormalMono_h #define _edoSamplerNormalMono_h +#include + #include #include "edoSampler.h" @@ -47,27 +49,25 @@ public: edoSamplerNormalMono( edoRepairer & repairer ) : edoSampler< D >( repairer) {} - EOT sample( edoNormalMono< EOT >& distrib ) + EOT sample( edoNormalMono& distrib ) { unsigned int size = distrib.size(); assert(size > 0); - // Point we want to sample to get higher a set of points + // The point we want to draw // (coordinates in n dimension) // x = {x1, x2, ..., xn} EOT solution; // Sampling all dimensions - for (unsigned int i = 0; i < size; ++i) - { + for (unsigned int i = 0; i < size; ++i) { AtomType mean = distrib.mean()[i]; AtomType variance = distrib.variance()[i]; - AtomType random = rng.normal(mean, variance); - - assert(variance >= 0); + // should use the standard deviation, which have the same scale than the mean + AtomType random = rng.normal(mean, sqrt(variance) ); solution.push_back(random); - } + } return solution; }