Skip to contents

A finite distribution draws its atoms with probability equal to their weights; a dirac() does so without changing the state of the pseudorandom number generator.

Rejection sampling from Dir(alpha), keeping the proposals the region contains.

Usage

draw(dist, n)

Arguments

dist

A distribution.

n

Number of draws.

Value

(n, K) numeric matrix.

Examples

set.seed(1)
fam <- multinomial_family(n_trials = 4L, k = 3L)
draw(fam(c(0.5, 0.3, 0.2)), n = 3L)
#>      [,1] [,2] [,3]
#> [1,]    1    1    2
#> [2,]    2    2    0
#> [3,]    2    0    2