Class Cmwc4096Random

  • All Implemented Interfaces:
    ByteArrayReseedableRandom, EntropyCountingRandom, RepeatableRandom, Dumpable, Serializable

    public class Cmwc4096Random
    extends BaseRandom

    A Java version of George Marsaglia's Complementary Multiply With Carry (CMWC) RNG. This is a very fast PRNG with an extremely long period (2131104). It should be used in preference to the MersenneTwisterRandom when a very long period is required.

    One potential drawback of this RNG is that it requires significantly more seed data than the other RNGs provided by Uncommons Maths. It requires just over 16 kilobytes, which may be a problem if your are obtaining seed data from a slow or limited entropy source. In contrast, the Mersenne Twister requires only 128 bits of seed data.

    NOTE: Because instances of this class require 16-kilobyte seeds, it is not possible to seed this RNG using the setSeed(long) method inherited from Random. Calls to this method will have no effect. Instead the seed must be set by a constructor.

    Since:
    1.2
    Author:
    Daniel Dyer
    See Also:
    Serialized Form
    • Constructor Detail

      • Cmwc4096Random

        public Cmwc4096Random()
                       throws SeedException
        Creates a new RNG and seeds it using the default seeding strategy.
        Throws:
        SeedException - if any.
      • Cmwc4096Random

        public Cmwc4096Random​(SeedGenerator seedGenerator)
                       throws SeedException
        Seed the RNG using the provided seed generation strategy.
        Parameters:
        seedGenerator - The seed generation strategy that will provide the seed value for this RNG.
        Throws:
        SeedException - If there is a problem generating a seed.
      • Cmwc4096Random

        public Cmwc4096Random​(byte[] seed)
        Creates an RNG and seeds it with the specified seed data.
        Parameters:
        seed - 16384 bytes of seed data used to initialize the RNG.