random: Random vs ThreadLocalRandom vs SecureRandom vs RandomGenerator module (seeds and a 2-output predictor, ranges and measured modulo bias, ThreadLocalRandom limits, SecureRandom algorithms and setSeed behaviour, the 13 java.util.random algorithms with split/jump, indicative timings), 16 contract tests

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ic4b6F5pq1M5ni1bNw8gr
This commit is contained in:
Claude
2026-11-19 22:50:44 +05:30
parent 4511cc6e6b
commit 59a5435825
22 changed files with 780 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
== The old classes already implement RandomGenerator ==
Random -> rollDie in 1..6: true
SecureRandom -> rollDie in 1..6: true
SplittableRandom -> rollDie in 1..6: true
ThreadLocalRandom -> rollDie in 1..6: true
== The default generator ==
RandomGenerator.getDefault() : jdk.internal.random.L32X64MixRandom
RandomGeneratorFactory.getDefault() : L32X64MixRandom
== Every algorithm this JDK ships (name, group, state bits, jumpable, splittable) ==
L128X1024MixRandom LXM 1152 bits jumpable=false splittable=true
L128X128MixRandom LXM 256 bits jumpable=false splittable=true
L128X256MixRandom LXM 384 bits jumpable=false splittable=true
L32X64MixRandom LXM 96 bits jumpable=false splittable=true
L64X1024MixRandom LXM 1088 bits jumpable=false splittable=true
L64X128MixRandom LXM 192 bits jumpable=false splittable=true
L64X128StarStarRandom LXM 192 bits jumpable=false splittable=true
L64X256MixRandom LXM 320 bits jumpable=false splittable=true
Random Legacy 48 bits jumpable=false splittable=false
SecureRandom Legacy 2147483647 bits jumpable=false splittable=false
SplittableRandom Legacy 64 bits jumpable=false splittable=true
Xoroshiro128PlusPlus Xoroshiro 128 bits jumpable=true splittable=false
Xoshiro256PlusPlus Xoshiro 256 bits jumpable=true splittable=false
== Pick an algorithm by name, and seed it ==
Xoshiro256PlusPlus seed 42 #1: 600 767 404
Xoshiro256PlusPlus seed 42 #2: 600 767 404
RandomGenerator.of("L64X128MixRandom") -> L64X128MixRandom
== Splittable: independent generators for parallel work ==
first draw of 4 split children: 952 921 97 912
== Jumpable: provably non-overlapping streams ==
jump distance : 3.402823669209385E38
leap distance : 6.277101735386681E57
original next: 600
after jump next: 545