SuanShu, a Java numerical and statistical library



com.numericalmethod.suanshu.stats.random.univariate.uniform.linear
Class MRG

java.lang.Object
  extended by com.numericalmethod.suanshu.stats.random.univariate.uniform.linear.MRG
All Implemented Interfaces:
Seedable, RandomLongGenerator, RandomNumberGenerator, LinearCongruentialGenerator

public class MRG
extends Object
implements LinearCongruentialGenerator

A Multiple Recursive Generator (MRG) is a linear congruential generator which takes this form:


 xi = (a1 * xi-1 + a2 * xi-2 + ... + ak * xi-k) mod m
 ui = xi / m
 

See Also:
"Paul Glasserman, "p. 44," Monte Carlo Methods in Financial Engineering, 2004."

Constructor Summary
MRG(long m, long... a)
          Construct a Multiple Recursive Generator.
 
Method Summary
 long modulus()
          Get the modulus of this linear congruential generator.
 double nextDouble()
          Get the next random double.
 long nextLong()
          Get the next random long.
 int order()
          Get the order of recursion.
 void seed(long... x)
          Seed the random number/vector/scenario generator to produce repeatable experiments.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MRG

public MRG(long m,
           long... a)
Construct a Multiple Recursive Generator.

Parameters:
m - the modulus
a - multipliers for the Lehmer rng (a long)
Method Detail

seed

public void seed(long... x)
Description copied from interface: Seedable
Seed the random number/vector/scenario generator to produce repeatable experiments.

Specified by:
seed in interface Seedable
Parameters:
x - the seeds

order

public int order()
Description copied from interface: LinearCongruentialGenerator
Get the order of recursion.

Specified by:
order in interface LinearCongruentialGenerator
Returns:
the order of recursion

modulus

public long modulus()
Description copied from interface: LinearCongruentialGenerator
Get the modulus of this linear congruential generator.

Specified by:
modulus in interface LinearCongruentialGenerator
Returns:
the modulus

nextLong

public long nextLong()
Description copied from interface: RandomLongGenerator
Get the next random long.

Specified by:
nextLong in interface RandomLongGenerator
Returns:
the next random long

nextDouble

public double nextDouble()
Description copied from interface: RandomNumberGenerator
Get the next random double.

Specified by:
nextDouble in interface RandomNumberGenerator
Returns:
the next random number


Copyright © 2010-2014 Numerical Method Incorporation Limited. All Rights Reserved.