org.jscience.measure.random
Class LuescherGenerator

java.lang.Object
  extended by org.jscience.measure.random.RandomElement
      extended by org.jscience.measure.random.RandomSeedable
          extended by org.jscience.measure.random.LuescherGenerator
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, RandomGenerator

public class LuescherGenerator
extends RandomSeedable
implements java.io.Serializable

RANLUX is an advanced pseudo-random number generator based on the RCARRY algorithm proposed in 1991 by Marsaglia and Zaman. RCARRY used a subtract-and-borrow algorithm with a period on the order of 10171 but still had detectable correlations between numbers. Martin Luescher proposed the RANLUX algorithm in 1993; RANLUX generates pseudo-random numbers using RCARRY but throws away numbers to destroy correlations. Thus RANLUX trades execution speed for quality; by choosing a larger luxury setting one gets better random numbers slower. By the tests availible at the time it was proposed, RANLUX at the default luxury setting appears to be a significant advance quality over previous generators.



LUXURY LEVELS
levelp
0 24 equivalent to the original RCARRY of Marsaglia and Zaman, very long period, but fails many tests.
148considerable improvement in quality over level 0, now passes the gap test, but still fails spectral test.
297 passes all known tests, but theoretically still defective.
3223 DEFAULT VALUE. Any theoretically possible correlations have very small chance of being observed.
4389highest possible luxury, all 24 bits chaotic.

VALIDATION

The Java version of RANLUX has been verified against published values of numbers 1-5 and 101-105 produced by the reference implementation of RANLUX for the following initial conditions:

References:

Source code is available.

See Also:
Serialized Form

Field Summary
static int lxdflt
          Default luxury level: lxdflt=3
static int maxlev
          Maximum luxury level: maxlev=4
 
Constructor Summary
LuescherGenerator()
          Default initialization of RANLUX.
LuescherGenerator(java.util.Date d)
          Initialize RANLUX with default luxury level and a Date object.
LuescherGenerator(int ins)
          Initialize RANLUX with default luxury level and a specified seed.
LuescherGenerator(int lux, java.util.Date d)
          Initialize RANLUX with specified luxury level and a Date object.
LuescherGenerator(int lux, int ins)
          Initialize RANLUX with specified luxury level and seed.
LuescherGenerator(int lux, long ins)
          Initialize RANLUX with specified luxury level and seed.
LuescherGenerator(long ins)
          Initialize RANLUX with default luxury level and a specified seed.
 
Method Summary
 double nextDouble()
          The random number generator.
 void setDiag(boolean b)
          Turns diagnostic messages on and off.
 
Methods inherited from class org.jscience.measure.random.RandomSeedable
ClockSeed, ClockSeed
 
Methods inherited from class org.jscience.measure.random.RandomElement
choose, choose, clone, coin, coin, gaussian, gaussian, nextDouble, nextDouble, powlaw, uniform
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

maxlev

public static final int maxlev
Maximum luxury level: maxlev=4

See Also:
Constant Field Values

lxdflt

public static final int lxdflt
Default luxury level: lxdflt=3

See Also:
Constant Field Values
Constructor Detail

LuescherGenerator

public LuescherGenerator()
Default initialization of RANLUX. Uses default seed jsdflt=314159265 and luxury level 3.


LuescherGenerator

public LuescherGenerator(int lux,
                         int ins)
Initialize RANLUX with specified luxury level and seed.

Parameters:
lux - luxury level from 0-4.
ins - seed, a positive integer.

LuescherGenerator

public LuescherGenerator(int lux,
                         long ins)
Initialize RANLUX with specified luxury level and seed.

Parameters:
lux - luxury level from 0-4.
ins - seed, a positive long.

LuescherGenerator

public LuescherGenerator(int ins)
Initialize RANLUX with default luxury level and a specified seed.

Parameters:
ins - seed, a positive integer

LuescherGenerator

public LuescherGenerator(long ins)
Initialize RANLUX with default luxury level and a specified seed.

Parameters:
ins - seed, a positive integer

LuescherGenerator

public LuescherGenerator(int lux,
                         java.util.Date d)
Initialize RANLUX with specified luxury level and a Date object. Can be used to conveniently initialize RANLUX from the clock,

 RandomElement e = Ranlux(4,new Date());
 

Parameters:
lux - luxury level from 0-4.
d - date used to generate seed

LuescherGenerator

public LuescherGenerator(java.util.Date d)
Initialize RANLUX with default luxury level and a Date object. Can be used to conveniently initialize RANLUX from the clock,

 RandomElement e = Ranlux(new Date());
 

Parameters:
d - date used to generate seed
Method Detail

setDiag

public void setDiag(boolean b)
Turns diagnostic messages on and off. If setDiag(true) is called, RANLUX will print diagnostic information to System.err

Parameters:
b - diagnostic message status

nextDouble

public final double nextDouble()
The random number generator.

Specified by:
nextDouble in interface RandomGenerator
Returns:
a random scalar