rDirichlet: Simulates from the Dirichlet distribution.

View source: R/distributions.R

rDirichletR Documentation

Simulates from the Dirichlet distribution.

Description

Simulates from the Dirichlet distribution.

Usage

rDirichlet(n, alpha)

Arguments

n

number of draws

alpha

vector with hyperparameters

Value

n-by-p matrix where each row is a draw.

Examples

library(bayeslearn)
draws = rDirichlet(n = 1000, alpha = c(3,5,10))
colMeans(draws) # Close to theoretical c(3,5,10)/18 = 0.167 0.278 0.556

StatisticsSU/bayeslearn documentation built on Feb. 2, 2023, 8:41 a.m.