It creates a sampler for the x object. It returns a function that accepts a parameter n denoting the number of samples to draw from the x object and also any additional parameters ... are passed to the generated function.

sampler(x, ...)

Arguments

x

the x object to create a sampler for

...

additional arguments to pass

Value

A function that takes n and returns n samples.

Examples

x <- normal(0, 1)
samp <- sampler(x)
set.seed(42)
samp(5)  # draw 5 samples from standard normal
#> [1]  1.3709584 -0.5646982  0.3631284  0.6328626  0.4042683