jebl.math
Class Random

java.lang.Object
  extended by jebl.math.Random

public class Random
extends Object

Random number generation.

Author:
Matthew Goode, Alexei Drummond

Method Summary
static double[] getNormalized(double[] array)
           
static double getTotal(double[] array)
           
static double getTotal(double[] array, int start, int end)
           
static boolean nextBoolean()
          Access a default instance of this class, access is synchronized
static byte nextByte()
          Access a default instance of this class, access is synchronized
static void nextBytes(byte[] bs)
          Access a default instance of this class, access is synchronized
static char nextChar()
          Access a default instance of this class, access is synchronized
static double nextDouble()
          Access a default instance of this class, access is synchronized
static float nextFloat()
          Access a default instance of this class, access is synchronized
static double nextGaussian()
          Access a default instance of this class, access is synchronized
static int nextInt()
          Access a default instance of this class, access is synchronized
static int nextInt(int n)
          Access a default instance of this class, access is synchronized
static long nextLong()
          Access a default instance of this class, access is synchronized
static short nextShort()
          Access a default instance of this class, access is synchronized
static int randomChoice(double[] cf)
           
static void setSeed(long seed)
          Access a default instance of this class, access is synchronized
static void shuffle(int[] array)
          Shuffles an array.
static void shuffle(int[] array, int numberOfShuffles)
          Shuffles an array.
static int[] shuffled(int l)
          Returns an array of shuffled indices of length l.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

randomChoice

public static int randomChoice(double[] cf)

getNormalized

public static double[] getNormalized(double[] array)
Returns:
a new double array where all the values sum to 1. Relative ratios are preserved.

getTotal

public static double getTotal(double[] array,
                              int start,
                              int end)
Parameters:
end - the index of the element after the last one to be included
Returns:
the total of a the values in a range of an array

getTotal

public static double getTotal(double[] array)
Returns:
the total of the values in an array

setSeed

public static void setSeed(long seed)
Access a default instance of this class, access is synchronized


nextByte

public static byte nextByte()
Access a default instance of this class, access is synchronized


nextBoolean

public static boolean nextBoolean()
Access a default instance of this class, access is synchronized


nextBytes

public static void nextBytes(byte[] bs)
Access a default instance of this class, access is synchronized


nextChar

public static char nextChar()
Access a default instance of this class, access is synchronized


nextGaussian

public static double nextGaussian()
Access a default instance of this class, access is synchronized


nextDouble

public static double nextDouble()
Access a default instance of this class, access is synchronized


nextFloat

public static float nextFloat()
Access a default instance of this class, access is synchronized


nextLong

public static long nextLong()
Access a default instance of this class, access is synchronized


nextShort

public static short nextShort()
Access a default instance of this class, access is synchronized


nextInt

public static int nextInt()
Access a default instance of this class, access is synchronized


nextInt

public static int nextInt(int n)
Access a default instance of this class, access is synchronized


shuffle

public static void shuffle(int[] array)
Shuffles an array.


shuffle

public static void shuffle(int[] array,
                           int numberOfShuffles)
Shuffles an array. Shuffles numberOfShuffles times


shuffled

public static int[] shuffled(int l)
Returns an array of shuffled indices of length l.

Parameters:
l - length of the array required.