40.6 Random numbers, seeds, threads, and stochastic equivalence
What you will learn
- Treat RNG mapping as part of the implementation
- Compare distributions rather than byte sequences across products
- Design reproducibility checks for stochastic workflows
Prerequisites: Chapter 39 troubleshooting, Chapter 36 command reference, and Chapter 38 output reference.
This page is scoped to nlmx 4.16.2 and an external-documentation snapshot of 2026-11-10. Product names describe different system boundaries; a blank or “outside role” is not a quality ranking. Treat every migration as a new implementation until model semantics, analysis population, objective definition, numerical behavior, outputs, and decisions have been independently reconciled.
A seed does not identify a universal random sequence. Generator family, stream derivation, ordering of subjects/replicates/chains, rejection behavior, process splitting, and algorithm consumption all matter. NONMEM documentation describes its simulation random-source options; PsN can split simulations into multiple NONMEM model runs, which may change sequence use. nlmx deliberately gives each subject/replicate a named stream and fixes reduction order so results are identical across --threads for a fixed version/configuration.
Therefore, never require nlmx and NONMEM/Monolix/PopED to produce the same simulated rows from the same integer seed. Validate distributions and downstream operating characteristics: means/variances/correlations, event counts, quantiles, coverage, power, type-I error, and Monte Carlo standard errors. Use enough independent seeds and prespecified statistical tolerances.
Within one product/version, test exact rerunability where promised: same inputs/seed/settings and different thread counts for nlmx; interrupted/resumed versus uninterrupted results; and stable replicate identifiers. Across versions, RNG derivation can be a breaking change even when distributions remain correct.
Record generator/version where exposed, seed, stream key, thread/process count, replicate allocation, rejected/redrawn samples, and reduction order. An apparent speed gain from fewer simulations or looser precision is not a valid comparison.
A useful stochastic test
Run at least several independent seeds and report the mean, between-seed SD, Monte Carlo SE, quantiles, and failure fraction of the target statistic. For a VPC, compare binwise simulated medians/interval coverage rather than replicate row 1. For SSE power, compare binomial confidence intervals and reasons failed replicates left the denominator. Within nlmx, add an exact hash comparison across thread counts because thread independence is a stated contract.
Primary source note: NONMEM 7.5 simulation/random-source behavior is documented in the pdfofficial NONMEM 7.5 introduction; PsN's VPC help documents how splitting simulations across NONMEM model files can affect sequences in the official PsN source.
Review checklist
- Are the exact product versions, task boundaries, inputs, methods, and settings named?
- Were semantics and frozen-parameter results aligned before optimized outputs?
- Is the comparison using a method-appropriate deterministic or stochastic tolerance?
- Are unsupported or analogous features described without implying equivalence?
- Can every claim be reproduced from retained primary evidence?
Navigation
See the previous page, next page, and complete comparison reference.