From 413446657c4db8d434abec2cbd98fc2ddb5955ee Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Wed, 15 Oct 2025 19:00:52 +0900 Subject: [PATCH] mruby-random: update readme to reflect pcg algorithm updates algorithm section to document the change from xoshiro128++ to PCG-XSH-RR. highlights key benefits including 50% memory reduction, platform-adaptive optimization, and excellent statistical quality. Co-authored-by: Claude --- mrbgems/mruby-random/README.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/mrbgems/mruby-random/README.md b/mrbgems/mruby-random/README.md index b57316b84..414dbe599 100644 --- a/mrbgems/mruby-random/README.md +++ b/mrbgems/mruby-random/README.md @@ -254,9 +254,18 @@ The `sample` method chooses one or more random elements from the array. ## Algorithm -The `mruby-random` mrbgem primarily utilizes the **xoshiro128++ 1.0** algorithm for pseudo-random number generation. +The `mruby-random` mrbgem uses the **PCG-XSH-RR** (Permuted Congruential Generator - XorShift High, Random Rotate) algorithm for pseudo-random number generation. -In certain 32-bit configurations (specifically when `MRB_INT32` is defined and `MRB_64BIT` is not), a different algorithm, **XORSHIFT96**, might be employed. +### Key Features + +- **Compact State**: Uses only 64 bits of state (compared to 128 bits in the previous xoshiro128++ implementation), reducing memory footprint by 50% +- **Excellent Statistical Quality**: Passes rigorous statistical test suites (TestU01, PractRand) +- **Platform-Optimized**: Automatically adapts to platform characteristics for optimal performance + - On **32-bit platforms** (`MRB_32BIT`): Uses an optimized 32-bit multiplier that requires only 2 multiply operations instead of 3 + - On **64-bit platforms**: Uses the standard 64-bit multiplier for maximum statistical quality +- **Fast Performance**: Competitive speed with modern PRNG algorithms while maintaining smaller memory footprint + +The PCG family of algorithms was developed by Melissa O'Neill and is widely used in production systems. For more details, see . ## License