From 485e5e160d75e883ea14c3bb08b352d63bdd32c2 Mon Sep 17 00:00:00 2001 From: "ray.j.greenwell" Date: Tue, 12 Oct 2010 01:20:26 +0000 Subject: [PATCH] getNormal() from Mark Johnson. git-svn-id: https://samskivert.googlecode.com/svn/trunk@2913 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- src/main/java/com/samskivert/util/Randoms.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/samskivert/util/Randoms.java b/src/main/java/com/samskivert/util/Randoms.java index f82593da..747681b1 100644 --- a/src/main/java/com/samskivert/util/Randoms.java +++ b/src/main/java/com/samskivert/util/Randoms.java @@ -126,13 +126,22 @@ public class Randoms } /** - * Returns true or false with approximately even probability. + * Returns true or false with approximately even probability. */ public boolean getBoolean () { return _r.nextBoolean(); } + /** + * Returns a pseudorandom, normally distributed float value around the + * mean with the standard deviation dev. + */ + public float getNormal (float mean, float dev) + { + return (float)_r.nextGaussian() * dev + mean; + } + /** * Returns a key from the supplied map according to a probability computed as * the key's value divided by the total of all the key's values.