Learn R Programming

hesim (version 0.2.3)

rdirichlet_mat: Random generation for multiple Dirichlet distributions

Description

Draw random samples from multiple Dirichlet distributions. rdirichlet_mat is vectorized and written in C++ for speed.

Usage

rdirichlet_mat(n, alpha)

Arguments

n

Number of samples to draw.

alpha

A matrix where each row is a separate vector of shape parameters.

Value

An array of matrices where each row of each matrix is a sample from the Dirichlet distribution.

Details

This function is particularly useful for representing the distribution of transition probabilities in a transition matrix.

Examples

Run this code
# NOT RUN {
alpha <- matrix(c(100, 200, 500, 50, 70, 75), ncol = 3, nrow = 2, byrow = TRUE)
samp <- rdirichlet_mat(100, alpha)
print(samp[, , 1:2])
# }

Run the code above in your browser using DataLab