You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To support a broader range of use-cases—statistical simulations, property-based testing, cryptography utilities, etc.—we should expand the Random API with advanced generators and enable deterministic reproducibility via seeding.
Motivation
Richer functionality
Advanced generators such as nextGaussian (normal distribution) and nextBytes ❓ unlock Monte Carlo algorithms, numeric simulations, realistic test data, and more.
Determinism & Reproducibility
Seeding the RNG is critical for writing repeatable tests and debugging non-deterministic issues.
Proposed API Additions
importin.rcard.yaes.RandomtraitRandom:
...
/** Gaussian (normal) distribution with mean 0.0 and std-dev 1.0 */defnextGaussian:Double/** Returns a new Random instance initialized with the specified seed */defwithSeed(seed: Long):Random
Implementation Sketch
Leverage java.util.random.RandomGenerator (Java 17+) under the hood for all methods. (now using scala.random package)
Acceptance Criteria
API surface
Implement nextGaussian.
Add withSeed(seed: Long) for deterministic instances.
Correctness
Property-based tests confirming Gaussian mean ≈ 0.0.
Uniformity tests for nextInt(n) and nextBytes.
Documentation
Update README with usage examples.
Compatibility
Preserve binary compatibility for existing calls to nextInt, nextDouble, and nextBoolean.
References
Java 17 RandomGenerator API – rich RNG support with seeding.
ScalaCheck – examples of deterministic generators in property-based tests.
Cats Effect (cats.effect.std.Random) – inspiration for method signatures and semantics.
The text was updated successfully, but these errors were encountered:
@haskiindahouse, if we use the Java RandomGenerator API, we'll also lose the chance to implement YAES for ScalaJs and ScalaNative. I know that the whole Async DSL is bound to the Java world, but I'd like to extend it in the future.
@haskiindahouse, as I said, the whole Async effect depends on Java Virtual Threads. So, the elephant in the room is there.
Let's move on with this issue and implement it. It will port the value to the library bound to Java. If needed, we'll study a multiplatform strategy in the future.
I assigned the issue to you if you'd like to proceed. Again, thanks for your time. 🙏
Summary
The current
Random
effect exposes only three basic methods:To support a broader range of use-cases—statistical simulations, property-based testing, cryptography utilities, etc.—we should expand the
Random
API with advanced generators and enable deterministic reproducibility via seeding.Motivation
Advanced generators such as
nextGaussian
(normal distribution) andnextBytes
❓ unlock Monte Carlo algorithms, numeric simulations, realistic test data, and more.Seeding the RNG is critical for writing repeatable tests and debugging non-deterministic issues.
Proposed API Additions
Implementation Sketch
java.util.random.RandomGenerator
(Java 17+) under the hood for all methods. (now using scala.random package)Acceptance Criteria
nextGaussian
.withSeed(seed: Long)
for deterministic instances.nextInt(n)
andnextBytes
.nextInt
,nextDouble
, andnextBoolean
.References
cats.effect.std.Random
) – inspiration for method signatures and semantics.The text was updated successfully, but these errors were encountered: