|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.randomness.Randomness
org.randomness.Quasirandomess
public abstract class Quasirandomess
This class specify Quasirandom Number Generator techniques for
quasirandom analogue of a random process which is a deterministic process
specifically designed so that simulation of the quasirandom process gives the
same limiting behavior (of some quantities of interest) as the random
process, but with faster convergence.
Most work on quasirandomness (also sometimes called subrandomness) has been motivated by Monte Carlo integration, and involves well-distributed sequences of points in some continuous space (e.g., the sequence of points in the interval [0,1] whose nth element is a0/2 + a1/4 + a2/8 + ..., where n = a0 + 2a1 + 4a< sub>2+ ..., or the sequence whose nth element is the fractional part of n times the golden ratio).
A series of numbers satisfying some mathematical random properties even though no random appearance is provided Good for Monte-Carlo methods Lower discrepancies offer better convergence
Constructor Summary | |
---|---|
Quasirandomess()
|
Method Summary | |
---|---|
Quasirandomess |
bakerTransformation()
Apply the baker's transformation to the output of this QRBG. |
void |
close()
The uninstantiate function zeroizes the internal state of RBG interrupting generate function, if proceed. |
boolean |
isOpen()
Tells whether or not this RBG is open to generate random bytes. |
int |
minlen()
Minlen is the minimum block of bytes essentially produced per one iteration of generate function (optional operation). |
int |
read(ByteBuffer dst)
The generate function generates the requested random bits using the generate algorithm. |
void |
reset()
The instantiate function determines the initial internal state of RBG using the instantiate algorithm. |
String |
toString()
Returns the name of the algorithm (or process) implemented by this RBG object (optional operation). |
int |
tryRead(ByteBuffer buffer)
Attempts to read from this RBG into the given buffer, if generate function is not owned by other thread. |
Methods inherited from class org.randomness.Randomness |
---|
asRandom, bind, map, mixing, newBuffer, nextBoolean, nextByte, nextChar, nextCharASCII, nextDouble, nextFloat, nextHexString, nextInt, nextInt, nextLong, nextLong, nextProbability, nextShort, read, read, read, readFuture, readSink, reversed, shuffle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Quasirandomess()
Method Detail |
---|
public boolean isOpen()
Randomness
isOpen
in interface Channel
isOpen
in class Randomness
public void reset()
Randomness
If RBG has already initiated a generate operation, then an invocation of this method will block until the first operation is complete. If RBG already initiated a generate function, then an invocation of instantiate function will block until the generate operation is complete.
Opposite to uninstantiate function.
reset
in class Randomness
public int read(ByteBuffer dst)
Randomness
Transfers a sequence generated bytes from this RBG into the given buffer. An attempt is made to read up to r bytes from RBG, where r is the number of bytes remaining in the buffer, that is, buffer.remaining(), at the moment this method is invoked.
Suppose that a byte sequence of length n is read, where 0 <= n <= r. This byte sequence will be transferred into the buffer so that the first byte in the sequence is at index p and the last byte is at index p + n - 1, where p is the buffer's position at the moment this method is invoked. Upon return the buffer's position will be equal to p + n; its limit will not have changed. As many bytes as possible are transferred into each buffer, hence the final position is guaranteed to be equal to that buffer's limit. Also, a read operation might not fill the buffer, and in fact it might not read any bytes at all. Whether or not it does so depends upon the nature and state of the RBG.
This method may be invoked at any time. If another thread has already initiated a read operation upon this RBG, however, then an invocation of this method will block until the first operation is complete.
Calling uninstantiate function in interrupt this metod normally (without exceptions).
read
in interface ReadableByteChannel
read
in class Randomness
dst
- The buffer into which random bytes are to be transferred.
public void close()
Randomness
After a RBG is closed, any further attempt to invoke
read operations upon it will
cause a NonReadableChannelException
to be thrown.
The closing status can be tested runtime via Randomness.isOpen() method.
The closed status of the RBG is cleared by reset function.
close
in interface Closeable
close
in interface Channel
close
in class Randomness
public String toString()
Randomness
In general case, toString
description can contain all
necessary information about RNG. If type of current RBG is undefined use
UNKNOWN
as type mark instead.
toString
in class Randomness
UNKNOWN
if the
algorithm name cannot be determined.public Quasirandomess bakerTransformation()
The baker transformation is often applied when the QRBG is actually an iterator over a point set used for quasi-Monte Carlo integration.
public int tryRead(ByteBuffer buffer)
Randomness
This method behaves exactly as specified in the generate function except that returns immediately if generate function is owned by other thread.
tryRead
in class Randomness
buffer
- The buffer into which random bytes are to be transferred.
public int minlen()
Randomness
This method may provide additional information about generator to configure generation process more essential for generator. For example, this method should used as follows:
Randomness rnd = Cryptorandomness.from(CSPRNG.SHA1);
ByteBuffer buffer = ByteBuffer.allocate(rnd.minlen() * MULTIPLIER);
rnd.read(buffer); // essential for generator. may be optimized.
minlen
in class Randomness
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |