# rprobdist: Generate a joint (or conditional) probability distribution In rje42/rje: Miscellaneous Useful Functions for Statistics

## Description

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

## Usage

 `1` ```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.

Robin Evans

## Examples

 ```1 2 3 4 5 6 7``` ```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) ```

rje42/rje documentation built on Dec. 10, 2018, 7:01 a.m.