public class Mover64RNG extends java.lang.Object implements RandomnessSource
LinnormRNG
and
TangleRNG
, but its period is unknown. The period is at the very least 2 to the 38, since each of its
sub-generators has been checked up to that period length without running out of period, and the total period of a
Mover64RNG should be greater than 2 to the 64 with a very high likelihood. The total period is also very unlikely to
be a power of two or even a number close to a power of two; it could be odd or even. The guarantees of Linnorm and
Tangle that they are certain to have a period of 2 to the 64 may be worthwhile reasons to use them; they also will be
faster when setting the state often. LightRNG is a SkippingRandomness and a StatefulRandomness, but this is neither,
so you may want to prefer LightRNG for that reason. This generator is not equidistributed, so it can return some long
values more often than others and some not at all; you may want to use a generator with guarantees on distribution if
you don't want to see some returned values (or pairs of values) more often than others. Starfish32RNG
is
2-dimensionally equidistributed for ints, so it returns all pairs of ints with equal likelihood, and it may be a good
RandomnessSource to use if distribution matters (though you should prefer GWTRNG
, which is implemented using
Starfish32RNG, because it is specialized to use a 32-bit generator).
setState(int)
, but it is unknown if that method
actually puts the generator in the longest possible cycle, or just a sufficiently long one.
Constructor and Description |
---|
Mover64RNG() |
Mover64RNG(int state) |
Mover64RNG(long stateA,
long stateB)
Not advised for external use; prefer
Mover64RNG(int) because it guarantees a good subcycle. |
Modifier and Type | Method and Description |
---|---|
Mover64RNG |
copy()
Produces a copy of this Mover64RNG that, if next() and/or nextLong() are called on this object and the
copy, both will generate the same sequence of random numbers from the point copy() was called.
|
boolean |
equals(java.lang.Object o) |
long |
getStateA()
Gets the "A" part of the state; if this generator was set with
Mover64RNG() , Mover64RNG(int) ,
or setState(int) , then this will be on the optimal subcycle, otherwise it may not be. |
long |
getStateB()
Gets the "B" part of the state; if this generator was set with
Mover64RNG() , Mover64RNG(int) ,
or setState(int) , then this will be on the optimal subcycle, otherwise it may not be. |
int |
hashCode() |
int |
next(int bits)
Using this method, any algorithm that might use the built-in Java Random
can interface with this randomness source.
|
int |
nextInt() |
long |
nextLong()
Using this method, any algorithm that needs to efficiently generate more
than 32 bits of random data can interface with this randomness source.
|
void |
setState(int s) |
void |
setStateA(long stateA)
Sets the "A" part of the state to any long, which may put the generator in a low-period subcycle.
|
void |
setStateB(long stateB)
Sets the "B" part of the state to any long, which may put the generator in a low-period subcycle.
|
java.lang.String |
toString() |
public Mover64RNG()
public Mover64RNG(int state)
public Mover64RNG(long stateA, long stateB)
Mover64RNG(int)
because it guarantees a good subcycle. This
constructor allows all subcycles to be produced, including ones with a shorter period.stateA
- stateB
- public void setState(int s)
public int nextInt()
public int next(int bits)
RandomnessSource
next
in interface RandomnessSource
bits
- the number of bits to be returnedpublic long nextLong()
RandomnessSource
nextLong
in interface RandomnessSource
public Mover64RNG copy()
copy
in interface RandomnessSource
public long getStateA()
Mover64RNG()
, Mover64RNG(int)
,
or setState(int)
, then this will be on the optimal subcycle, otherwise it may not be.public long getStateB()
Mover64RNG()
, Mover64RNG(int)
,
or setState(int)
, then this will be on the optimal subcycle, otherwise it may not be.public void setStateA(long stateA)
setState(int)
to guarantee a good subcycle.stateA
- any intpublic void setStateB(long stateB)
setState(int)
to guarantee a good subcycle.stateB
- any intpublic java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
Copyright © Eben Howard 2012–2022. All rights reserved.