From a6fc0df110e74a4b04bfba4b730a8e596cda344d Mon Sep 17 00:00:00 2001 From: Keith Peters Date: Sat, 1 Jan 2022 19:07:20 -0500 Subject: [PATCH] decrease stdev of gaussrange func --- random/random.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/random/random.go b/random/random.go index 85c344f..7f8c690 100644 --- a/random/random.go +++ b/random/random.go @@ -76,7 +76,11 @@ func GaussRange(min, max float64) float64 { rng := (max - min) / 2.0 mean := min + rng // a standard deviation of 1.0 will have 99.7% of its values between -3 and +3. - std := rng / 3.0 + // but for 100,000 samples, that's still around 300 points beyond that range. + // 99.994% will be between -4 and 4. + // for 100,000 samples, that's around 6 outside the range. better. + // so we get the standard deviation by dividing the range by 4.0 + std := rng / 4.0 return rand.NormFloat64()*std + mean }