All Downloads are FREE. Search and download functionalities are using the official Maven repository.

src.it.unimi.dsi.util.package-info Maven / Gradle / Ivy

Go to download

The DSI utilities are a mishmash of classes accumulated during the last twenty years in projects developed at the DSI (Dipartimento di Scienze dell'Informazione, i.e., Information Sciences Department), now DI (Dipartimento di Informatica, i.e., Informatics Department), of the Universita` degli Studi di Milano.

There is a newer version: 2.7.3
Show newest version
/**
 * 

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.8251.4501.4821.5531.8501.5242.1351.8762.157 *
nextInt(100000) 7.3912.4002.8052.8582.9332.4073.2662.7543.509 *
nextDouble() 15.8252.1252.4342.4532.5032.1052.8022.3823.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;





© 2015 - 2024 Weber Informatics LLC | Privacy Policy