Class XorShift64StarRandom

java.lang.Object
java.util.Random
it.unimi.dsi.util.XorShift64StarRandom
All Implemented Interfaces:
Serializable, java.util.random.RandomGenerator

@Deprecated public class XorShift64StarRandom extends Random
Deprecated.
Use SplitMix64Random instead.
A fast, good-quality pseudorandom number generator that combines George Marsaglia's Xorshift generators (described in “Xorshift RNGs”, Journal of Statistical Software, 8:1−6, 2003) with a multiplication.
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from interface java.util.random.RandomGenerator

    java.util.random.RandomGenerator.ArbitrarilyJumpableGenerator, java.util.random.RandomGenerator.JumpableGenerator, java.util.random.RandomGenerator.LeapableGenerator, java.util.random.RandomGenerator.SplittableGenerator, java.util.random.RandomGenerator.StreamableGenerator
  • Constructor Summary

    Constructors
    Constructor
    Description
    Deprecated.
    Creates a new generator seeded using Util.randomSeed().
    Deprecated.
    Creates a new generator using a given seed.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected int
    next(int bits)
    Deprecated.
     
    boolean
    Deprecated.
     
    void
    nextBytes(byte[] bytes)
    Deprecated.
     
    double
    Deprecated.
     
    float
    Deprecated.
     
    int
    Deprecated.
     
    int
    nextInt(int n)
    Deprecated.
    Returns a pseudorandom, approximately uniformly distributed int value between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator's sequence.
    long
    Deprecated.
     
    long
    nextLong(long n)
    Deprecated.
    Returns a pseudorandom uniformly distributed long value between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator's sequence.
    void
    setSeed(long seed)
    Deprecated.
    Sets the seed of this generator.
    void
    setState(long state)
    Deprecated.
    Sets the state of this generator.

    Methods inherited from class java.util.Random

    doubles, doubles, doubles, doubles, ints, ints, ints, ints, longs, longs, longs, longs, nextGaussian

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.util.random.RandomGenerator

    isDeprecated, nextDouble, nextDouble, nextExponential, nextFloat, nextFloat, nextGaussian, nextInt, nextLong
  • Constructor Details

    • XorShift64StarRandom

      public XorShift64StarRandom()
      Deprecated.
      Creates a new generator seeded using Util.randomSeed().
    • XorShift64StarRandom

      public XorShift64StarRandom(long seed)
      Deprecated.
      Creates a new generator using a given seed.
      Parameters:
      seed - a nonzero seed for the generator (if zero, the generator will be seeded with Long.MIN_VALUE).
  • Method Details

    • next

      protected int next(int bits)
      Deprecated.
      Overrides:
      next in class Random
    • nextLong

      public long nextLong()
      Deprecated.
      Specified by:
      nextLong in interface java.util.random.RandomGenerator
      Overrides:
      nextLong in class Random
    • nextInt

      public int nextInt()
      Deprecated.
      Specified by:
      nextInt in interface java.util.random.RandomGenerator
      Overrides:
      nextInt in class Random
    • nextInt

      public int nextInt(int n)
      Deprecated.
      Returns a pseudorandom, approximately uniformly distributed int value between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator's sequence.

      The hedge “approximately” is due to the fact that to be always faster than ThreadLocalRandom we return the upper 63 bits of nextLong() modulo n instead of using Random's fancy algorithm (which nextLong(long) uses though). This choice introduces a bias: the numbers from 0 to 263 mod n are slightly more likely than the other ones. In the worst case, “more likely” means 1.00000000023 times more likely, which is in practice undetectable (actually, due to the abysmally low quality of Random's generator, the result is statistically better in any case than Random.nextInt(int)'s) .

      If for some reason you need truly uniform generation, just use nextLong(long).

      Specified by:
      nextInt in interface java.util.random.RandomGenerator
      Overrides:
      nextInt in class Random
      Parameters:
      n - the positive bound on the random number to be returned.
      Returns:
      the next pseudorandom int value between 0 (inclusive) and n (exclusive).
    • nextLong

      public long nextLong(long n)
      Deprecated.
      Returns a pseudorandom uniformly distributed long value between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator's sequence. The algorithm used to generate the value guarantees that the result is uniform, provided that the sequence of 64-bit values produced by this generator is.
      Parameters:
      n - the positive bound on the random number to be returned.
      Returns:
      the next pseudorandom long value between 0 (inclusive) and n (exclusive).
    • nextDouble

      public double nextDouble()
      Deprecated.
      Specified by:
      nextDouble in interface java.util.random.RandomGenerator
      Overrides:
      nextDouble in class Random
    • nextFloat

      public float nextFloat()
      Deprecated.
      Specified by:
      nextFloat in interface java.util.random.RandomGenerator
      Overrides:
      nextFloat in class Random
    • nextBoolean

      public boolean nextBoolean()
      Deprecated.
      Specified by:
      nextBoolean in interface java.util.random.RandomGenerator
      Overrides:
      nextBoolean in class Random
    • nextBytes

      public void nextBytes(byte[] bytes)
      Deprecated.
      Specified by:
      nextBytes in interface java.util.random.RandomGenerator
      Overrides:
      nextBytes in class Random
    • setSeed

      public void setSeed(long seed)
      Deprecated.
      Sets the seed of this generator.

      The seed will be passed through HashCommon.murmurHash3(long). In this way, if the user passes a small value we will avoid the short irregular transient associated with states with a very small number of bits set.

      Overrides:
      setSeed in class Random
      Parameters:
      seed - a nonzero seed for this generator (if zero, the generator will be seeded with Long.MIN_VALUE).
    • setState

      public void setState(long state)
      Deprecated.
      Sets the state of this generator.
      Parameters:
      state - the new state for this generator (must be nonzero).