getNormal() from Mark Johnson.

git-svn-id: https://samskivert.googlecode.com/svn/trunk@2913 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
ray.j.greenwell
2010-10-12 01:20:26 +00:00
parent 4ac0865946
commit 485e5e160d
+10 -1
View File
@@ -126,13 +126,22 @@ public class Randoms
} }
/** /**
* Returns <code>true</code> or <code>false</code> with approximately even probability. * Returns <code>true</code> or <code>false</code> with approximately even probability.
*/ */
public boolean getBoolean () public boolean getBoolean ()
{ {
return _r.nextBoolean(); return _r.nextBoolean();
} }
/**
* Returns a pseudorandom, normally distributed <code>float</code> value around the
* <code>mean</code> with the standard deviation <code>dev</code>.
*/
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 * 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. * the key's value divided by the total of all the key's values.