|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
ObjectMultiRandSelector<T>
public class MultiRandSelector<T>
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 |
|---|
public MultiRandSelector(int num_elts,
Partitioner<T,T> eq)
num_elts - the number of elements to select from each
bucketeq - partioner that determines how to partition the objects from
the iteration.
public MultiRandSelector(double keep_prob,
Partitioner<T,T> eq)
public MultiRandSelector(int num_elts,
Random r,
Partitioner<T,T> eq)
public MultiRandSelector(double keep_prob,
Random r,
Partitioner<T,T> eq)
| Method Detail |
|---|
public void acceptIter(Iterator<T> iter)
public void accept(T next)
public Map<T,RandomSelector<T>> values()
public Iterator<T> valuesIter()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||