com.softsynth.jmsl
Class JMSLRandom

java.lang.Object
  extended by com.softsynth.jmsl.JMSLRandom

public class JMSLRandom
extends java.lang.Object

Random number class. Algorithm from Cooper/Clancy "Oh! Pascal!"

Author:
Phil Burk and Nick Didkovsky

Field Summary
static int NUM_GAUSS_LOOPS
          The higher the number of loops, the better gauss() approximates bell curve (Central Limit Theorem Method).
 
Constructor Summary
JMSLRandom()
           
 
Method Summary
static double choose()
           
static double choose(double high)
           
static double choose(double low, double high)
           
static int choose(int high)
           
static int choose(int low, int high)
           
static double choosePlusMinus(double range)
          return random double between +range and -range
static int choosePlusMinus(int range)
          return random integer between +range and -range, inclusive
static double gauss(double sigma, double xmu)
          Return a Gaussian distributed value using Central Limit Theorem Method.
static int getSeed()
           
static void main(java.lang.String[] args)
           
static int nextSeed()
           
static int qa()
           
static void randomize()
          set random seed from time.
static void setSeed(int s)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NUM_GAUSS_LOOPS

public static int NUM_GAUSS_LOOPS
The higher the number of loops, the better gauss() approximates bell curve (Central Limit Theorem Method). Defaults to 20, see http://www.dspguru.com/howto/tech/wgn2.htm

Constructor Detail

JMSLRandom

public JMSLRandom()
Method Detail

randomize

public static void randomize()
set random seed from time. Call getSeed() to store the random seed generated here


setSeed

public static void setSeed(int s)

getSeed

public static int getSeed()
Returns:
current seed

nextSeed

public static int nextSeed()

choose

public static double choose()
Returns:
random float [0..1)

choose

public static int choose(int high)
Returns:
random int [0..high)

choose

public static double choose(double high)
Returns:
random double [0..high)

choose

public static int choose(int low,
                         int high)
Returns:
random int [low..high)

choose

public static double choose(double low,
                            double high)
Returns:
random double [low..high)

choosePlusMinus

public static int choosePlusMinus(int range)
return random integer between +range and -range, inclusive


choosePlusMinus

public static double choosePlusMinus(double range)
return random double between +range and -range


gauss

public static double gauss(double sigma,
                           double xmu)
Return a Gaussian distributed value using Central Limit Theorem Method. sigma (standard deviation) controls narrowness of bell, xmu (mean) controls the centering of bell. Small sigmas make narrow bells. Comments from Matt Donadio at http://www.dspguru.com/howto/tech/wgn2.htm, "The drawback to this method is that X will be in the range [-N, N], instead of (-Infinity, Infinity) and if the calls to uniform are not truly independent, then the noise will no longer be white. Jeruchim, et. al., recommend N >=20 for good results."


qa

public static int qa()

main

public static void main(java.lang.String[] args)