Learn R Programming

estimators (version 0.7.3)

ddirich: The Dirichlet Distribution

Description

Density function and random generation for the Dirichlet distribution with parameter vector shape.

Usage

ddirich(x, shape, log = FALSE)

rdirich(n, shape)

Value

ddirich returns a numeric vector (the evaluated density function). rdirich returns a matrix with length(shape) rows and n

columns.

Arguments

x

numeric. The quantile vector.

shape

numeric. The parameter vector.

log

logical. If TRUE, probabilities p are given as log(p).

n

numeric. The number of observations.

Examples

Run this code
# Classic R Stats Format
ddirich(c(0.3, 0.7), shape = c(2, 3))
set.seed(1)
rdirich(10, shape = c(2, 3))

# S4 Distribution Class
library(distr)
D <- Dirichlet(shape = c(2, 3))
d(D)(c(0.3, 0.7))
set.seed(1)
r(D)(10)

Run the code above in your browser using DataLab