Parallel Colt 0.7.2

cern.jet.random.tdouble.sampling
Class WeightedDoubleRandomSampler

java.lang.Object
  extended by cern.colt.PersistentObject
      extended by cern.jet.random.tdouble.sampling.WeightedDoubleRandomSampler
All Implemented Interfaces:
Serializable, Cloneable

public class WeightedDoubleRandomSampler
extends PersistentObject

Conveniently computes a stable subsequence of elements from a given input sequence; Picks (samples) exactly one random element from successive blocks of weight input elements each. For example, if weight==2 (a block is 2 elements), and the input is 5*2=10 elements long, then picks 5 random elements from the 10 elements such that one element is randomly picked from the first block, one element from the second block, ..., one element from the last block. weight == 1.0 --> all elements are picked (sampled). weight == 10.0 --> Picks one random element from successive blocks of 10 elements each. Etc. The subsequence is guaranteed to be stable, i.e. elements never change position relative to each other.

Version:
1.0, 02/05/99
Author:
wolfgang.hoschek@cern.ch
See Also:
Serialized Form

Field Summary
 
Fields inherited from class cern.colt.PersistentObject
serialVersionUID
 
Constructor Summary
WeightedDoubleRandomSampler()
          Calls BlockedRandomSampler(1,null).
WeightedDoubleRandomSampler(int weight, DoubleRandomEngine randomGenerator)
          Chooses exactly one random element from successive blocks of weight input elements each.
 
Method Summary
 Object clone()
          Returns a deep copy of the receiver.
 int getWeight()
           
 boolean sampleNextElement()
          Chooses exactly one random element from successive blocks of weight input elements each.
 void setWeight(int weight)
          Not yet commented.
static void test(int weight, int size)
          Not yet commented.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WeightedDoubleRandomSampler

public WeightedDoubleRandomSampler()
Calls BlockedRandomSampler(1,null).


WeightedDoubleRandomSampler

public WeightedDoubleRandomSampler(int weight,
                                   DoubleRandomEngine randomGenerator)
Chooses exactly one random element from successive blocks of weight input elements each. For example, if weight==2, and the input is 5*2=10 elements long, then chooses 5 random elements from the 10 elements such that one is chosen from the first block, one from the second, ..., one from the last block. weight == 1.0 --> all elements are consumed (sampled). 10.0 --> Consumes one random element from successive blocks of 10 elements each. Etc.

Parameters:
weight - the weight.
randomGenerator - a random number generator. Set this parameter to null to use the default random number generator.
Method Detail

clone

public Object clone()
Returns a deep copy of the receiver.

Overrides:
clone in class PersistentObject
Returns:
a copy of the receiver.

getWeight

public int getWeight()

sampleNextElement

public boolean sampleNextElement()
Chooses exactly one random element from successive blocks of weight input elements each. For example, if weight==2, and the input is 5*2=10 elements long, then chooses 5 random elements from the 10 elements such that one is chosen from the first block, one from the second, ..., one from the last block.

Returns:
true if the next element shall be sampled (picked), false otherwise.

setWeight

public void setWeight(int weight)
Not yet commented.

Parameters:
weight - int

test

public static void test(int weight,
                        int size)
Not yet commented.


Parallel Colt 0.7.2

Jump to the Parallel Colt Homepage