utilMDE
Class MultiRandSelector<T>

Object
  extended by MultiRandSelector<T>

public class MultiRandSelector<T>
extends Object

MultiRandSelector, like RandomSelector, performs a uniform random selection over an iteration of objects. However, the objects in the iteration may be partitioned so that the random selection chooses the same number from each group. For example, given data about incomes by state, it may be more useful to select 1000 people from each state rather than 50,000 from the nation. Also, for selecting invocations in a Daikon trace file, it may be more useful to select an equal number of samples per program point.

The performance is the equal to running a set of RandomSelector Objects, one for each bucket, as well as some overhead for determining which bucket to assign to each Object in the iteration.

To use this class, call this.accept() on every Object in the iteration to be sampled. Then, call valuesIter() to receive an iteration of all the values selected by the random selection.


Constructor Summary
MultiRandSelector(double keep_prob, Partitioner<T,T> eq)
           
MultiRandSelector(double keep_prob, Random r, Partitioner<T,T> eq)
           
MultiRandSelector(int num_elts, Partitioner<T,T> eq)
           
MultiRandSelector(int num_elts, Random r, Partitioner<T,T> eq)
           
 
Method Summary
 void accept(T next)
           
 void acceptIter(Iterator<T> iter)
           
 Map<T,RandomSelector<T>> values()
          NOT safe from concurrent modification.
 Iterator<T> valuesIter()
          Returns an iterator of all objects selected.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiRandSelector

public MultiRandSelector(int num_elts,
                         Partitioner<T,T> eq)
Parameters:
num_elts - the number of elements to select from each bucket
eq - partioner that determines how to partition the objects from the iteration.

MultiRandSelector

public MultiRandSelector(double keep_prob,
                         Partitioner<T,T> eq)

MultiRandSelector

public MultiRandSelector(int num_elts,
                         Random r,
                         Partitioner<T,T> eq)

MultiRandSelector

public MultiRandSelector(double keep_prob,
                         Random r,
                         Partitioner<T,T> eq)
Method Detail

acceptIter

public void acceptIter(Iterator<T> iter)

accept

public void accept(T next)

values

public Map<T,RandomSelector<T>> values()
NOT safe from concurrent modification.


valuesIter

public Iterator<T> valuesIter()
Returns an iterator of all objects selected.