rprobdist: Generate a joint (or conditional) probability distribution

rprobdistR Documentation

Generate a joint (or conditional) probability distribution

Description

Wrapper functions to quickly generate discrete joint (or conditional) distributions using Dirichlets

Usage

rprobdist(dim, d, cond, alpha = 1)

Arguments

dim

the joint dimension of the probability table

d

number of dimensions

cond

optionally, vertices to condition upon

alpha

Dirichlet hyper parameter, defaults to 1 (flat density).

Details

rprobdist gives an array of dimension dim (recycled as necessary to have length d, if this is supplied) whose entries are probabilities drawn from a Dirichlet distribution whose parameter vector has entries equal to alpha (appropriately recycled).

Value

an array of appropriate dimensions

Side Effects

Uses as many gamma random variables as cells in the table, so will alter the random seed accordingly.

Author(s)

Robin Evans

Examples

rprobdist(2, 4)     # 2x2x2x2 table
rprobdist(c(2,3,2)) # 2x3x2 table

rprobdist(2, 4, alpha=1/16)     # using unit information prior

# get variables 2 and 4 conditioned upon
rprobdist(2, 4, cond=c(2,4), alpha=1/16) 


rje documentation built on Nov. 12, 2022, 9:06 a.m.