Package elki.utilities.random
Class XorShift1024NonThreadsafeRandom
- java.lang.Object
-
- java.util.Random
-
- elki.utilities.random.XorShift1024NonThreadsafeRandom
-
- All Implemented Interfaces:
java.io.Serializable
@Reference(authors="S. Vigna", title="An experimental exploration of Marsaglia\'s xorshift generators, scrambled", booktitle="Online", url="http://vigna.di.unimi.it/ftp/papers/xorshift.pdf", bibkey="web/Vigna14") public class XorShift1024NonThreadsafeRandom extends java.util.Random
Replacement for Java'sRandomclass, using a different random number generation strategy. Java's random generator is optimized for speed, but may lack the randomness needed for more complex experiments.This approach is based on the work on XorShift1024* by Sebastiano Vigna, with the original copyright statement:
Written in 2014 by Sebastiano Vigna (vigna@acm.org)
To the extent possible under law, the author has dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
See http://creativecommons.org/publicdomain/zero/1.0/
- Since:
- 0.7.0
- Author:
- Erich Schubert
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.StringBADBOUNDException message for non-positive bounds(package private) intpFor rotating amongst statesprivate static longserialVersionUIDSerial version number.private long[]xState of random number generator.
-
Constructor Summary
Constructors Constructor Description XorShift1024NonThreadsafeRandom()Constructor called only by localRandom.initialValue.XorShift1024NonThreadsafeRandom(long seed)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected intnext(int bits)doublenextDouble()intnextInt()intnextInt(int n)Returns a pseudorandom, uniformly distributedintvalue between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator's sequence.longnextLong()voidsetSeed(long seed)
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
Serial version number.- See Also:
- Constant Field Values
-
x
private long[] x
State of random number generator.
-
p
int p
For rotating amongst states
-
BADBOUND
protected static final java.lang.String BADBOUND
Exception message for non-positive bounds- See Also:
- Constant Field Values
-
-
Method Detail
-
setSeed
public void setSeed(long seed)
- Overrides:
setSeedin classjava.util.Random
-
nextLong
public long nextLong()
- Overrides:
nextLongin classjava.util.Random
-
next
protected int next(int bits)
- Overrides:
nextin classjava.util.Random
-
nextInt
public int nextInt()
- Overrides:
nextIntin classjava.util.Random
-
nextDouble
public double nextDouble()
- Overrides:
nextDoublein classjava.util.Random
-
nextInt
@Reference(authors="D. Lemire", title="Fast random shuffling", booktitle="Daniel Lemire\'s blog", url="http://lemire.me/blog/2016/06/30/fast-random-shuffling/", bibkey="blog/Lemire16") public int nextInt(int n)
Returns a pseudorandom, uniformly distributedintvalue between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator's sequence. The general contract ofnextIntis that oneintvalue in the specified range is pseudorandomly generated and returned. Allnpossibleintvalues are produced with (approximately) equal probability.In contrast to the Java version, we use an approach that tries to avoid divisions for performance discussed in:
D. Lemire
Fast random shuffling
http://lemire.me/blog/2016/06/30/fast-random-shuffling/- Overrides:
nextIntin classjava.util.Random
-
-