src.it.unimi.dsi.util.package-info Maven / Gradle / Ivy
Show all versions of dsiutils Show documentation
/**
* Miscellaneaous utility classes.
*
*
Pseudorandom number generators
*
* We provide a number of fast, high-quality PRNGs with different features. You can get detailed
* information about the generators at our PRNG page, together
* with a reasoned guide to the choice of the generator that's right for you.
*
*
A table summarizing timings is provided below. The timings were measured on an
* Intel® Core™ i7-7700 CPU @ 3.60GHz (Kaby Lake),
* and they are now obtained by means of
* JMH microbenchmarks. The JMH timings were decreased by 1ns, as
* using the low-level {@code perfasm} profiler the JMH overhead was estimated at ≈1ns per call.
*
*
*
* {@link java.util.Random Random}
* {@link java.util.concurrent.ThreadLocalRandom ThreadLocalRandom}
* {@link java.util.SplittableRandom SplittableRandom}
* {@link it.unimi.dsi.util.SplitMix64RandomGenerator SplitMix64}
* {@link it.unimi.dsi.util.XoRoShiRo128StarStarRandom xoroshiro128**
}
* {@link it.unimi.dsi.util.XoRoShiRo128PlusRandom xoroshiro128+
}
* {@link it.unimi.dsi.util.XoShiRo256StarStarRandom xoshiro256**
}
* {@link it.unimi.dsi.util.XoShiRo256PlusRandom xoshiro256+
}
* {@link it.unimi.dsi.util.XorShift1024StarPhiRandom xorshift1024*φ
}
*
* nextLong() 15.825 1.450 1.482 1.553 1.850 1.524 2.135 1.876 2.157
* nextInt(100000) 7.391 2.400 2.805 2.858 2.933 2.407 3.266 2.754 3.509
* nextDouble() 15.825 2.125 2.434 2.453 2.503 2.105 2.802 2.382 3.077
*
*
* Note that generators that are extremely fast in C, such as xoshiro256+
, do not perform particularly well in Java, most likely
* because of the cost of accessing variables, which rises as the size of the state space grows.
*
*
For each generator, we provide a version that extends {@link java.util.Random}, overriding (as usual) the {@link java.util.Random#next(int) next(int)} method. Nonetheless,
* since the generators are all inherently 64-bit also {@link java.util.Random#nextInt() nextInt()}, {@link java.util.Random#nextFloat() nextFloat()},
* {@link java.util.Random#nextLong() nextLong()}, {@link java.util.Random#nextDouble() nextDouble()}, {@link java.util.Random#nextBoolean() nextBoolean()}
* and {@link java.util.Random#nextBytes(byte[]) nextBytes(byte[])} have been overridden for speed (preserving, of course, {@link java.util.Random}'s semantics).
*
*
If you do not need an instance of {@link java.util.Random}, or if you need a {@link org.apache.commons.math3.random.RandomGenerator} to use
* with Commons Math, there is for each generator a corresponding {@link org.apache.commons.math3.random.RandomGenerator RandomGenerator}
* implementation, which indeed we suggest to use in general if you do not need a generator implementing {@link java.util.Random}.
*/
package it.unimi.dsi.util;