manifest_record_seed() stores the generator's kind and its full
state in the manifest; manifest_restore_seed() puts both back.
Together they let a run that used randomness be repeated exactly.
Arguments
- manifest
A manifest, as from
make_manifest().
Value
manifest_record_seed() the manifest with an rng
element; manifest_restore_seed() the manifest, invisibly, having
set the generator.
Details
Why the state and not just a seed. set.seed(1) is reproducible
only if everything before it is too: a single extra draw anywhere
upstream shifts every subsequent value. Recording .Random.seed as
it stood pins the actual position in the stream, and recording
RNGkind() alongside it pins what that position means – R has
changed its default sample() algorithm before, and a seed
replayed under a different kind gives different numbers with no warning.
This is opt-in because the state is 626 integers, which is a lot of manifest for an analysis with no randomness in it.