jbil.util
Class RandomUtilities

java.lang.Object
  extended by jbil.util.RandomUtilities

public class RandomUtilities
extends java.lang.Object

Assorted Random utility functions.

Author:
Paulo G. S. da Fonseca

Constructor Summary
RandomUtilities()
           
 
Method Summary
static int[] pickAtRandom(int howMany, int upperLimit)
          Pick integers at random with equal probabilities and without repositions in the range from 0 up to a given upper limit (not inclusive).
static int[] shuffle(int N)
          Creates an array containing the elements 0...N-1 in random order.
static void shuffle(int[] v)
          Shuffles an int array.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RandomUtilities

public RandomUtilities()
Method Detail

shuffle

public static int[] shuffle(int N)
Creates an array containing the elements 0...N-1 in random order.

Parameters:
N - The number of the elements of the array.

shuffle

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

Parameters:
v - the array to be shuffled.

pickAtRandom

public static int[] pickAtRandom(int howMany,
                                 int upperLimit)
Pick integers at random with equal probabilities and without repositions in the range from 0 up to a given upper limit (not inclusive).

Parameters:
howMany - How many integers to pick
upperLimit - the upper limit value (not inclusive)
Returns:
A sorted vector of howMany integers in the range 0...upperLimit-1