|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.softsynth.jmsl.util.SequencerGeneratorAdapter com.softsynth.jmsl.util.WeightedIntegerSequence
public class WeightedIntegerSequence
Define an array of weights where the weight of int i is associated with the value weights[i]
next() chooses an int 0..weights.length-1, following a weighted distribution
For example, the weight array { 1.0, 1.0 } will generate values 0 and 1 with a 50/50 distribution
The weight array { 1, 2, 1 } will generate ints 0, 1, 2, with the probability of 1 being chosen twice as high
as the probability of 0 or 2 being chosen.
Constructor Summary | |
---|---|
WeightedIntegerSequence(double[] weights)
Loaded with indexes 0..weights.length, where each int is assigned the weight in weights[i] |
Method Summary | |
---|---|
int[] |
getDistribution()
|
int |
getNext()
Peek ahead. |
double[] |
getWeights()
|
static void |
main(java.lang.String[] args)
|
int |
next()
Return next value in sequence, then generate a new one. |
void |
setNext(int next)
UNIMPLEMENTED |
Methods inherited from class com.softsynth.jmsl.util.SequencerGeneratorAdapter |
---|
getSeed, randomize, reset, setSeed |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public WeightedIntegerSequence(double[] weights)
Method Detail |
---|
public int[] getDistribution()
public double[] getWeights()
public int next()
SequenceGenerator
public void setNext(int next)
SequenceGenerator.setNext(int)
public int getNext()
getNext
in interface SequenceGenerator
getNext
in class SequencerGeneratorAdapter
public static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |