Copyright 2008 - 2010 Tony Morris, Runar Bjarnason, Tom Adams, Brad Clow, Ricky Clarkson, Nick Partridge, Jason Zaugg

This software is released under an open source BSD licence.

fj.test
Class Rand

java.lang.Object
  extended by fj.test.Rand

public final class Rand
extends Object

A random number generator.


Field Summary
static Rand standard
          A standard random generator that uses Random.
 
Method Summary
 double choose(double from, double to)
          Randomly chooses a value between the given range (inclusive).
 int choose(int from, int to)
          Randomly chooses a value between the given range (inclusive).
 double choose(long seed, double from, double to)
          Randomly chooses a value between the given range (inclusive).
 int choose(long seed, int from, int to)
          Randomly chooses a value between the given range (inclusive).
static Rand rand(F<Option<Long>,F<Integer,F<Integer,Integer>>> f, F<Option<Long>,F<Double,F<Double,Double>>> g)
          Constructs a random generator from the given functions that supply a range to produce a result.
 Rand reseed(long seed)
          Gives this random generator a new seed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

standard

public static final Rand standard
A standard random generator that uses Random.

Method Detail

choose

public int choose(long seed,
                  int from,
                  int to)
Randomly chooses a value between the given range (inclusive).

Parameters:
seed - The seed to use for random generation.
from - The minimum value to choose.
to - The maximum value to choose.
Returns:
A random value in the given range.

choose

public int choose(int from,
                  int to)
Randomly chooses a value between the given range (inclusive).

Parameters:
from - The minimum value to choose.
to - The maximum value to choose.
Returns:
A random value in the given range.

choose

public double choose(long seed,
                     double from,
                     double to)
Randomly chooses a value between the given range (inclusive).

Parameters:
seed - The seed to use for random generation.
from - The minimum value to choose.
to - The maximum value to choose.
Returns:
A random value in the given range.

choose

public double choose(double from,
                     double to)
Randomly chooses a value between the given range (inclusive).

Parameters:
from - The minimum value to choose.
to - The maximum value to choose.
Returns:
A random value in the given range.

reseed

public Rand reseed(long seed)
Gives this random generator a new seed.

Parameters:
seed - The seed of the new random generator.
Returns:
A random generator with the given seed.

rand

public static Rand rand(F<Option<Long>,F<Integer,F<Integer,Integer>>> f,
                        F<Option<Long>,F<Double,F<Double,Double>>> g)
Constructs a random generator from the given functions that supply a range to produce a result.

Parameters:
f - The integer random generator.
g - The floating-point random generator.
Returns:
A random generator from the given functions that supply a range to produce a result.

Copyright 2008 - 2010 Tony Morris, Runar Bjarnason, Tom Adams, Brad Clow, Ricky Clarkson, Nick Partridge, Jason Zaugg

This software is released under an open source BSD licence.