rdirichlet: Random draws from and density for Dirichlet distribution

Description Usage Arguments Details Value Note References Examples

View source: R/dirichlet.R

Description

Generate draws from a random Dirichlet distribution or compute its density.

Usage

1
2
rdirichlet(n, alpha)
ddirichlet(x, alpha)

Arguments

n

Number of draws

alpha

Scale matrix, h x h

x

value to compute density

Details

Draws n values for an h x h Dirichlet random variable or computes the density.

Value

x

An n x h matrix of the draws

Note

Based on code from Kevin Quinn in the MCMCpack package and the gregmisc package.

References

MCMCpack and gregmisc

Examples

1
rdirichlet(2, matrix(rep(1, 4), 2, 2))

Example output

##
## MSBVAR Package v.0.9-2
## Build date:  Fri May 10 08:07:03 2019 
## Copyright (C) 2005-2019, Patrick T. Brandt
## Written by Patrick T. Brandt
##
## Support provided by the U.S. National Science Foundation
## (Grants SES-0351179, SES-0351205, SES-0540816, and SES-0921051)
##

           [,1]       [,2]      [,3]       [,4]
[1,] 0.74271508 0.01906666 0.2046823 0.03353597
[2,] 0.05777596 0.25311355 0.6382755 0.05083500

MSBVAR documentation built on May 30, 2017, 1:23 a.m.

Related to rdirichlet in MSBVAR...