Skip to contents

Directly sample from a model. Not all models support this, and an error will be thrown if it is not possible.

Usage

monty_model_direct_sample(model, rng, named = FALSE)

Arguments

model

A monty_model object

rng

Random number state, created by monty_rng_create. 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.

Value

A vector or matrix of sampled parameters

Examples

m <- monty_example("banana")

r <- monty_rng_create()
monty_model_direct_sample(m, r)
#> [1] -0.3783996 -0.1044199
monty_model_direct_sample(m, r, named = TRUE)
#>     alpha      beta 
#> 1.2506604 0.1703702 

r <- monty_rng_create(n_streams = 3)
monty_model_direct_sample(m, r)
#>             [,1]       [,2]        [,3]
#> alpha  0.5541374  0.7505752 -0.39650839
#> beta  -1.1328500 -0.4231797 -0.08241687
monty_model_direct_sample(m, r, named = TRUE)
#>            [,1]     [,2]       [,3]
#> alpha  2.680949 3.770176 -0.1416292
#> beta  -1.757684 1.564376 -0.4359825