rdirichlet_mat: Random generation for multiple Dirichlet distributions
Description
Draw random samples from multiple Dirichlet distributions for use in
transition probability matrices.
Usage
rdirichlet_mat(
n,
alpha,
output = c("array", "matrix", "data.frame", "data.table")
)
Value
If output = "array", then an array of matrices is returned
where each row of each matrix is a sample from the Dirichlet distribution.
If output results in a two dimensional object (i.e., a matrix,
data.frame, or data.table, then each row contains
all elements of the sampled matrix from the Dirichlet distribution
ordered rowwise; that is, each matrix is flattened. In these cases,
the number of rows must be less than or equal to the number of columns.
Arguments
n
Number of samples to draw.
alpha
A matrix where each row is a separate vector of shape parameters.
output
The class of the object returned by the function. Either an
array, matrix, data.frame, or data.table.
Details
This function is meant for representing the distribution of
transition probabilities in a transition matrix. The (i,j) element of
alpha is a transition from state i to state j. It is vectorized and
written in C++ for speed.