net.sf.doodleproject.numerics4j.random
Class LinearCongruentialRNG

java.lang.Object
  extended by net.sf.doodleproject.numerics4j.random.LinearCongruentialRNG
All Implemented Interfaces:
RNG

public class LinearCongruentialRNG
extends java.lang.Object
implements RNG

A general linear congruential generator.

References:

  1. Wikipedia contributors, "Linear congruential generator," Wikipedia, The Free Encyclopedia, http://en.wikipedia.org/wiki/Linear_congruential_generator

Since:
1.3
Version:
$Revision: 1.3 $ $Date: 2007/11/18 23:51:19 $

Constructor Summary
LinearCongruentialRNG(long m, long a)
          Create a linear congruential generator with the given modulus and multiplier.
LinearCongruentialRNG(long m, long a, long c)
          Create a linear congruential generator with the given parameters.
LinearCongruentialRNG(long m, long a, long c, long s)
          Create a linear congruential generator with the given parameters.
 
Method Summary
 double nextRandomNumber()
          Access the next random number from this generator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LinearCongruentialRNG

public LinearCongruentialRNG(long m,
                             long a)
Create a linear congruential generator with the given modulus and multiplier. The shift is set to zero.

Parameters:
m - the modulus.
a - the multiplier.

LinearCongruentialRNG

public LinearCongruentialRNG(long m,
                             long a,
                             long c)
Create a linear congruential generator with the given parameters.

Parameters:
m - the modulus.
a - the multiplier.
c - the shift.

LinearCongruentialRNG

public LinearCongruentialRNG(long m,
                             long a,
                             long c,
                             long s)
Create a linear congruential generator with the given parameters.

Parameters:
m - the modulus.
a - the multiplier.
c - the shift.
s - the seed.
Method Detail

nextRandomNumber

public double nextRandomNumber()
Access the next random number from this generator.

Specified by:
nextRandomNumber in interface RNG
Returns:
the next random number.


Copyright 2004-2004-2007 DoodleProject. All Rights Reserved.