edu.uconn.mcb.lineageevolver
Class RandomSelection

java.lang.Object
  extended byedu.uconn.mcb.lineageevolver.RandomSelection

public class RandomSelection
extends java.lang.Object

Class used for weighted random selection of an element in a set, given discrete relative probabilities (weights) between elements in the set.

Author:
Hasan Khalil, Lina Pezzella

Field Summary
private  float[] _probabilities
          The probability of selection per element in the n-tuple.
private  float _total
          The sum of all probabilities in the provided array.
private static java.util.Random randomNumberGenerator
          Random number generator shared amongst all RandomSelection classes.
 
Constructor Summary
RandomSelection(float[] probabilities)
          Default constructor for objects of type RandomSelection.
 
Method Summary
 int select()
          Returns a random selection, weighted according to the probabilities.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_total

private float _total
The sum of all probabilities in the provided array.


_probabilities

private float[] _probabilities
The probability of selection per element in the n-tuple.


randomNumberGenerator

private static java.util.Random randomNumberGenerator
Random number generator shared amongst all RandomSelection classes.

Constructor Detail

RandomSelection

public RandomSelection(float[] probabilities)
Default constructor for objects of type RandomSelection.

Parameters:
probabilities - the discrete probabilities associated to each element in the n-tuple for weighted selection.
Method Detail

select

public int select()
Returns a random selection, weighted according to the probabilities.

Returns:
a random selection