Simulates from a Dirichlet distribution with concentration parameter vector \(\alpha\) = (\(\alpha_1\), ..., \(\alpha_K\)).
rDir(n = 1, alpha = c(1, 1))
A numeric scalar. The size of sample required.
A numeric vector. Dirichlet concentration parameter.
An n
by length(alpha)
numeric matrix.
The simulation is based on the property that if \(Y_1, \ldots, Y_K\) are independent, \(Y_i\) has a gamma(\(\alpha_i\), 1) distribution and \(S = Y_1 + \cdots + Y_k\) then \((Y_1, \ldots, Y_K) / S\) has a Dirichlet(\(\alpha_1\), ..., \(\alpha_K\)) distribution.
See https://en.wikipedia.org/wiki/Dirichlet_distribution#Gamma_distribution
Kotz, S., Balakrishnan, N. and Johnson, N. L. (2000) Continuous Multivariate Distributions, vol. 1, Models and Applications, 2nd edn, ch. 49. New York: Wiley. doi:10.1002/0471722065
rprior_prob
for prior simulation of
GEV parameters - prior on probability scale.
rDir(n = 10, alpha = 1:4)
#> [,1] [,2] [,3] [,4]
#> [1,] 0.042927170 0.38588616 0.3743211 0.1968656
#> [2,] 0.088497195 0.03327438 0.3222989 0.5559295
#> [3,] 0.197067019 0.14144038 0.2239492 0.4375434
#> [4,] 0.084516534 0.15946901 0.3628196 0.3931949
#> [5,] 0.037054281 0.26493184 0.1312302 0.5667837
#> [6,] 0.283073278 0.10635877 0.2342739 0.3762940
#> [7,] 0.238457766 0.19905808 0.4060322 0.1564520
#> [8,] 0.054461292 0.14081343 0.4113885 0.3933368
#> [9,] 0.056388458 0.07547971 0.5521652 0.3159666
#> [10,] 0.004435328 0.05672812 0.2382670 0.7005695