com.jsyn.util
Class PseudoRandom

java.lang.Object
  extended by com.jsyn.util.PseudoRandom

public class PseudoRandom
extends java.lang.Object

Pseudo-random numbers using predictable and fast linear-congruential method.


Constructor Summary
PseudoRandom()
          Create an instance of SynthRandom.
PseudoRandom(int seed)
          Create an instance of PseudoRandom.
 
Method Summary
 int choose(int range)
           
 int getSeed()
           
 double nextRandomDouble()
          Returns the next random double from -1.0 to 1.0
 int nextRandomInteger()
          Calculate random 32 bit number using linear-congruential method.
 double random()
          Returns the next random double from 0.0 to 1.0
 void setSeed(int seed)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PseudoRandom

public PseudoRandom()
Create an instance of SynthRandom.


PseudoRandom

public PseudoRandom(int seed)
Create an instance of PseudoRandom.

Method Detail

setSeed

public void setSeed(int seed)

getSeed

public int getSeed()

random

public double random()
Returns the next random double from 0.0 to 1.0

Returns:
value from 0.0 to 1.0

nextRandomDouble

public double nextRandomDouble()
Returns the next random double from -1.0 to 1.0

Returns:
value from -1.0 to 1.0

nextRandomInteger

public int nextRandomInteger()
Calculate random 32 bit number using linear-congruential method.


choose

public int choose(int range)