Packagecom.threerings.util
Classpublic class RandomUtil

Random Random utilities.



Public Methods
 MethodDefined by
  
getWeightedIndex(weights:Array, randomFn:Function = null):int
[static] Return the picked index from a weighted list.
RandomUtil
  
pickRandom(values:Array, randomFn:Function = null):Object
[static] Picks a random object from the supplied array of values.
RandomUtil
Method detail
getWeightedIndex()method
public static function getWeightedIndex(weights:Array, randomFn:Function = null):int

Return the picked index from a weighted list.

Parameters
weights:Array — an Array containing Numbers, ints, or uints. All values should be non-negative.
 
randomFn:Function (default = null) — random function that returns (0 <= value < 1), if null then Math.random() will be used.

Returns
int
pickRandom()method 
public static function pickRandom(values:Array, randomFn:Function = null):Object

Picks a random object from the supplied array of values. Even weight is given to all elements of the array.

Parameters
values:Array
 
randomFn:Function (default = null)

Returns
Object — a randomly selected item or null if the array is null or of length zero.