| 1750 | /** @internal Draw the next uniform in [0, 1). |
| 1751 | * |
| 1752 | * Inside a `WithRandomSeed` frame the draw is the counter-based |
| 1753 | * `hash(seed, n)` of the innermost frame, and the frame's counter advances |
| 1754 | * (u32, wrapping). Outside any frame the draw is LIVE (`Math.random()`): |
| 1755 | * there is no ambient seed to set, so an unframed draw is |
| 1756 | * non-deterministic by construction. |
| 1757 | */ |
| 1758 | _random(): number { |
| 1759 | const frame = this._runtimeState.randomFrame; |
| 1760 | if (frame !== undefined) { |
| 1761 | const n = frame.next >>> 0; |
| 1762 | frame.next = (frame.next + 1) >>> 0; |
| 1763 | return frameDraw(frame.seedLo, frame.seedHi, n); |
| 1764 | } |
| 1765 | return Math.random(); |
| 1766 | } |
| 1767 | |
| 1768 | /** @internal A private stream derived from the ambient `WithRandomSeed` |
| 1769 | * frame, for the stochastic ESTIMATORS (Monte-Carlo integration, the |
| 1770 | * sampled equality probe). |
| 1771 | * |
| 1772 | * Unlike `_random()`, this consumes NO indices from the frame: an estimator |
| 1773 | * that samples 1e7 points must not shift a sibling `Random()` draw, and its |