Skip to contents

Lookup function for RNGs via string identifier

Usage

rng_lookup(family)

Arguments

family

String identifier of the likelihood family to get an RNG for.

Value

The RNG function.

Examples

rng_lookup("gamma")
#> function (n, mu = 1, a = 1) 
#> {
#>     if (isTRUE(a <= 0)) {
#>         stop("gamma is only defined for a > 0")
#>     }
#>     if (isTRUE(mu <= 0)) {
#>         stop("gamma is only defined for mu > 0")
#>     }
#>     return(rgamma(n = n, shape = a, rate = a/mu))
#> }
#> <bytecode: 0x562df78852f0>
#> <environment: namespace:bayesfam>
do.call(rng_lookup("gaussian"), list(n = 100, mean = 0, sd = 1))
#>   [1]  0.137726925  0.546795423 -0.784745747  0.534951877  0.387592404
#>   [6] -0.071368602 -2.187106130  1.155767690 -1.427428272 -0.435545185
#>  [11]  1.974470266 -0.279485262 -1.023458637 -0.064898657  1.305223196
#>  [16]  0.518327895 -0.072793572 -0.379973974 -0.459500697 -0.304582976
#>  [21]  0.374359783  0.341024830 -0.850066266  1.322841531 -0.225952101
#>  [26] -0.756193593  0.168972599  0.745285981 -0.853999459 -0.741229465
#>  [31] -0.752959424  0.454064715 -1.311131860 -2.231629551 -0.008646871
#>  [36] -0.498968098 -0.082095421 -0.858891171  0.274875834  0.878312185
#>  [41]  0.358699788  1.381157995 -1.253396828  0.443892685 -0.524053222
#>  [46]  0.516648107  0.537172134  0.270755028  1.022916510  0.343683435
#>  [51] -0.008879731 -0.138136290  1.260733240 -0.238782452  1.462505837
#>  [56] -1.048476391 -0.631171398  1.062246648 -1.206634264  0.801127358
#>  [61]  0.263760168  0.618933091 -0.699590000  0.359641377  0.006138428
#>  [66] -2.119735819  1.064372073  1.741117968 -1.284929599  0.055845065
#>  [71] -0.820418275 -0.260215358  0.836307319  0.366602630 -0.386106998
#>  [76] -0.148670154  1.539359636  0.907431975 -0.888352315 -1.676259290
#>  [81]  0.689273140 -1.087523946  1.486817699 -0.376430847  0.423667103
#>  [86] -0.460457112 -0.734204429 -0.319602543  1.394306918 -0.244538380
#>  [91] -0.455191375 -0.039325311  0.376585743  0.260301181  2.706077392
#>  [96]  0.014877073  1.174928811 -0.658625133  1.861034972 -1.401512563