uk.ac.ed.inf.utils.stats
Class UniformRandomUtils

java.lang.Object
  extended by uk.ac.ed.inf.utils.stats.UniformRandomUtils

public class UniformRandomUtils
extends java.lang.Object

Utilities for extracting with uniform random distribution

Version:
29 Jun 2008
Author:
Luna De Ferrari luna.deferrari-at-ed.ac.uk

Constructor Summary
UniformRandomUtils()
           
 
Method Summary
static int extractInteger(int size)
          Returns a random integer between 0 and (size-1)
static java.util.Map.Entry extractUniformRandomMapEntry(java.util.Map map)
          Extracts a random entry (key-value association) from a map
static java.util.Map getUniformRandomSubmap(java.util.Map map, double percentage)
          Returns a submap of randomly picked map entries
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UniformRandomUtils

public UniformRandomUtils()
Method Detail

extractInteger

public static int extractInteger(int size)
Returns a random integer between 0 and (size-1)

Parameters:
size - size-1 is the biggest integer that can be extracted
Returns:
a random integer between 0 and (size-1)

extractUniformRandomMapEntry

public static java.util.Map.Entry extractUniformRandomMapEntry(java.util.Map map)
Extracts a random entry (key-value association) from a map

Parameters:
map - a map
Returns:
a random (uniform probability) entry from the map

getUniformRandomSubmap

public static java.util.Map getUniformRandomSubmap(java.util.Map map,
                                                   double percentage)
Returns a submap of randomly picked map entries

Parameters:
map - the original map
percentage - the percentage of the original map to be put in the submap
Returns:
the random submap