SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.stats.random.distribution
Class Uniform

java.lang.Object
  extended by com.numericalmethod.suanshu.stats.random.distribution.Uniform
All Implemented Interfaces:
RandomLongGenerator, RandomNumberGenerator

public class Uniform
extends java.lang.Object
implements RandomLongGenerator

A pseudo uniform random number generator generates numbers within the unit interval in such a way that there are equal probabilities of them falling in the same length sub-interval.

Sampling from the unit interval is the most basic building block of most pseudo random number generation algorithms.

Note that the numbers generated are in [0, 1].

See Also:
Wikipedia: Uniform distribution (continuous)

Nested Class Summary
static class Uniform.Method
          the different pseudo uniform random number generators available
 
Field Summary
 Uniform.Method method
          the sampling algorithm
 
Constructor Summary
Uniform()
          Construct a Mersenne Twister pseudo uniform random number generator.
Uniform(Uniform.Method method)
          Construct a pseudo uniform random number generator.
 
Method Summary
 double nextDouble()
          Get the next random double between 0 and 1.
 long nextLong()
          Get the next random long.
 void seed(long... seeds)
          Seed the random number generator to produce repeatable sequences.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

method

public final Uniform.Method method
the sampling algorithm

Constructor Detail

Uniform

public Uniform(Uniform.Method method)
Construct a pseudo uniform random number generator.

Parameters:
method - the algorithm to use

Uniform

public Uniform()
Construct a Mersenne Twister pseudo uniform random number generator.

Method Detail

seed

public void seed(long... seeds)
Description copied from interface: RandomNumberGenerator
Seed the random number generator to produce repeatable sequences.

Specified by:
seed in interface RandomNumberGenerator
Parameters:
seeds - the seeds

nextDouble

public double nextDouble()
Get the next random double between 0 and 1.

Specified by:
nextDouble in interface RandomNumberGenerator
Returns:
the next random number between 0 and 1

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

SuanShu, a Java numerical and statistical library

Copyright © 2011 Numerical Method Inc. Ltd. All Rights Reserved.