rvdirichlet: Generate Random Variables from a Dirichlet Sampling Model

Description Usage Arguments Details Value Author(s) References Examples

View source: R/rvdirichlet.R

Description

Generates random variables from a Dirichlet sampling model.

Usage

1
  rvdirichlet(n=1, alpha)

Arguments

n

integer: number of vectors to generate

alpha

the parameter vector; may be random

Details

The Dirichlet distribution is a generalization of the Beta distribution. (If alpha is of length two, rvdirichlet draws from the Beta model.)

Value

A random vector (rv object) of length n.

Author(s)

Jouni Kerman [email protected]

References

Kerman, J. and Gelman, A. (2007). Manipulating and Summarizing Posterior Simulations Using Random Variable Objects. Statistics and Computing 17:3, 235-244.

See also vignette("rv").

Examples

1
2
  a <- rvdirichlet(1, alpha=c(6, 3, 1)) # 
  sum(a) # one with probability 1

Example output

Loading required package: parallel
    mean      sd 1% 2.5% 25% 50% 75% 97.5% 99% sims
[1]    1 5.2e-17  1    1   1   1   1     1   1 4000

rv documentation built on May 29, 2017, 8:53 p.m.