Package jebl.math
Class Random
java.lang.Object
jebl.math.Random
Random number generation.
- Version:
- $Id: Random.java 370 2006-06-29 18:57:56Z rambaut $
- Author:
- Matthew Goode, Alexei Drummond
-
Method Summary
Modifier and TypeMethodDescriptionstatic double[]
getNormalized
(double[] array) static double
getTotal
(double[] array) static double
getTotal
(double[] array, int start, int end) static boolean
Access a default instance of this class, access is synchronizedstatic byte
nextByte()
Access a default instance of this class, access is synchronizedstatic void
nextBytes
(byte[] bs) Access a default instance of this class, access is synchronizedstatic char
nextChar()
Access a default instance of this class, access is synchronizedstatic double
Access a default instance of this class, access is synchronizedstatic float
Access a default instance of this class, access is synchronizedstatic double
Access a default instance of this class, access is synchronizedstatic int
nextInt()
Access a default instance of this class, access is synchronizedstatic int
nextInt
(int n) Access a default instance of this class, access is synchronizedstatic long
nextLong()
Access a default instance of this class, access is synchronizedstatic short
Access a default instance of this class, access is synchronizedstatic int
randomChoice
(double[] cf) static void
setSeed
(long seed) Access a default instance of this class, access is synchronizedstatic 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.
-
Method Details
-
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.
-