Skip to contents

Every random number zulm draws (parameter initialisation, noise inside graphs, zl_rng_uniform() and zl_rng_normal()) comes from 'zurand' under a key derived from the session key and a name. zl_seed() sets the session key from a whole number, or from a key made with zurand::rng_key() or zurand::rng_fold(); with no argument it returns the current key. Until it is set, the key is drawn once from R's generator, so set.seed() before the first draw governs a session.

Usage

zl_seed(seed = NULL)

Arguments

seed

NULL to get the key; a whole number from 0 to .Machine$integer.max, or a zurand rng_key of length one, to set it.

Value

The session key; when setting, the previous key, invisibly.

Examples

old <- zl_seed(42)
zl_rng_normal(3, "example")
#> [1] 0.3497453 0.3490455 0.2920494
zl_seed(old)