Versioned deterministic random stream state and bounded draws (#10) #26

Merged
faumaray merged 1 commits from issue/10-versioned-rng-state into main 2026-12-03 08:08:25 +00:00
Owner

Closes #10.

Branch issue/10-versioned-rng-state targeting main. Summary, tests and the documented contracts are in the commit message and the issue comment.

Closes #10. Branch `issue/10-versioned-rng-state` targeting `main`. Summary, tests and the documented contracts are in the commit message and the issue comment.
faumaray added 1 commit 2026-12-03 06:49:28 +00:00
- Public, versioned State (algorithm identity "xoshiro256**", schema
  version 1, four words in s0..s3 order) so consumers can define their
  own wire format.
- restore() validates version and rejects the absorbing all-zero state
  without touching the current stream; from_state() builds a generator
  from saved state.
- bounded(n): unbiased rejection sampling in [0, n). Documented
  zero-bound policy: n == 0 and n == 1 return 0 without consuming
  randomness.
- 7 new tests freeze raw/bounded/state outputs for seed 42 (portable
  across targets), verify save/restore suffix equality, invalid-state
  rejection, zero/one bounds, large non-power-of-two ranges,
  independent interleaved streams and discard equivalence.
faumaray merged commit a0e4bfa941 into main 2026-12-03 08:08:25 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Void/Library#26