Directly sample from a model. Not all models support this, and an error will be thrown if it is not possible.
Arguments
- model
A monty_model object
- rng
Random number state, created by monty_rng. Use of an RNG with more than one stream may or may not work as expected; this is something we need to tidy up (
mrc-5292
)- named
Logical, indicating if the output should be named using the parameter names.
Examples
m <- monty_example("banana")
r <- monty_rng$new()
monty_model_direct_sample(m, r)
#> [1] 0.01091672 -0.51496028
monty_model_direct_sample(m, r, named = TRUE)
#> alpha beta
#> 0.4310525 -0.2160027
r <- monty_rng$new(n_streams = 3)
monty_model_direct_sample(m, r)
#> [,1] [,2] [,3]
#> [1,] 0.2147504 1.207777 -1.095091
#> [2,] -0.5453002 1.268223 0.113292
monty_model_direct_sample(m, r, named = TRUE)
#> [,1] [,2] [,3]
#> alpha -0.5961543 -0.4538435 -0.1738595
#> beta 0.3813224 0.5014159 -0.7288189