|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.rubecula.util.random.Randomizer
public class Randomizer
Title: Randomizer
Description: this class extends RandomGenerator
to play a kind of
roulette wheel game. A set of relative frequencies is defined for each
"band". The result of calling nextIndex() is to return an index into the
band. Obviously, the higher the frequency of the band, the more likely the
index is going to point to that particular band.
For the roulette wheel game, there would be 37 (38 in the USA) bands defined
with equal frequency. Unless of course you were setting up a crooked roulette
wheel, in which case you would increase (slightly, presumably) the frequency
of your favorite band.
Copyright: Copyright (c) 2003
Company: Rubecula Software, LLC
Constructor Summary | |
---|---|
Randomizer()
Deprecated. |
|
Randomizer(int[] bands)
Deprecated. |
|
Randomizer(int[] bands,
boolean reseed)
Deprecated. |
|
Randomizer(int[] bands,
long seed)
Deprecated. |
|
Randomizer(long seed)
Deprecated. |
|
Randomizer(org.apache.commons.math.random.RandomGenerator random)
Construct a randomizer with an empty array of band widths, and using the specified random number generator. |
|
Randomizer(org.apache.commons.math.random.RandomGenerator random,
int[] bands)
Construct a randomizer with an array of band widths, and using the specified random number generator. |
|
Randomizer(org.apache.commons.math.random.RandomGenerator random,
int[] bands,
boolean reseed)
Primary constructor. |
Method Summary | |
---|---|
int[] |
getBands()
|
int |
getTotal()
|
boolean |
nextBoolean()
|
void |
nextBytes(byte[] bytes)
|
double |
nextDouble()
|
float |
nextFloat()
|
double |
nextGaussian()
|
int |
nextIndex()
The behavior of this method depends on whether any bands were defined for this randomizer. |
int |
nextInt()
|
int |
nextInt(int n)
|
long |
nextLong()
|
void |
setBands(int[] bands)
|
void |
setOdds(int odds)
|
void |
setSeed(long seed)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
@Deprecated public Randomizer()
Random_Standard
with no specified seed. The RNG will not be
reseeded after each call.
@Deprecated public Randomizer(int[] bands)
Random_Standard
with no specified seed. The RNG will not be
reseeded after each call.
bands
- An array of longs which give the relative frequencies desired
for each band.@Deprecated public Randomizer(int[] bands, boolean reseed)
Random_Standard
with no specified seed.
bands
- An array of longs which give the relative frequencies desired
for each band.reseed
- true if the randomizer is to be reseeded before every
randomizing call. This is good when the calls are made
according to e.g. clicks in a user interface or updates from a
web service. Otherwise, the numbers follow a pseudo-random
number generator sequence.@Deprecated public Randomizer(int[] bands, long seed)
Random_Standard
with the specified seed. The RNG will not be
reseeded after each call.
bands
- An array of longs which give the relative frequencies desired
for each band.seed
- the seed for the first random number.@Deprecated public Randomizer(long seed)
Random_Standard
with the specified seed. The RNG will not be
reseeded after each call.
seed
- the seed for the first random number.public Randomizer(org.apache.commons.math.random.RandomGenerator random)
random
- a random number generator.public Randomizer(org.apache.commons.math.random.RandomGenerator random, int[] bands)
random
- bands
- An array of longs which give the relative frequencies desired
for each band.public Randomizer(org.apache.commons.math.random.RandomGenerator random, int[] bands, boolean reseed)
random
- a random number generator.bands
- reseed
- if true, the RNG will be reseeded after each call (using the
system clock).Method Detail |
---|
public int[] getBands()
_Bands
public int getTotal()
_Total
public boolean nextBoolean()
nextBoolean
in interface org.apache.commons.math.random.RandomGenerator
RandomGenerator.nextBoolean()
public void nextBytes(byte[] bytes)
nextBytes
in interface org.apache.commons.math.random.RandomGenerator
RandomGenerator.nextBytes(byte[])
public double nextDouble()
nextDouble
in interface org.apache.commons.math.random.RandomGenerator
RandomGenerator.nextDouble()
public float nextFloat()
nextFloat
in interface org.apache.commons.math.random.RandomGenerator
RandomGenerator.nextFloat()
public double nextGaussian()
nextGaussian
in interface org.apache.commons.math.random.RandomGenerator
RandomGenerator.nextGaussian()
public int nextIndex()
Integer.MAX_VALUE
. In both cases, the
superclass method RandomGenerator.nextInt(int)
is called.
public int nextInt()
nextInt
in interface org.apache.commons.math.random.RandomGenerator
RandomGenerator.nextInt()
public int nextInt(int n)
nextInt
in interface org.apache.commons.math.random.RandomGenerator
RandomGenerator.nextInt(int)
public long nextLong()
nextLong
in interface org.apache.commons.math.random.RandomGenerator
RandomGenerator.nextLong()
public void setBands(int[] bands)
bands
- public void setOdds(int odds)
odds
- the odds.public void setSeed(long seed)
setSeed
in interface org.apache.commons.math.random.RandomGenerator
RandomGenerator.setSeed(long)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |