randCPTs: A function to generate random CPTs for a given DAG

Description Usage Arguments Value

View source: R/randCPTs.R

Description

This function randomly generate conditional probability tables (CPTs) for a given DAG, with specified maximum arity and concentration parameter from a symmetric Dirichlet distribution. Values of variables are sampled from capital alphabet letters, A, B, ... The function has dependency on the library gtools on its rdirichlet() function.

Usage

1
randCPTs(dag, maxArity, beta, arities = NULL, debug = FALSE)

Arguments

dag

A DAG in the bnlearn format.

maxArity

The maximum arity for variables. That is, the maximum number of values that a variable can have.

beta

The concentration parameter is a symmetric Dirichlet distribution. When beta=1, it is the same as sampling from uniform distribution; when beta>1, CPT values are more likeliy to be equal since they are sampled from a center-peaked n-1 simplex; when beta<1, CPT values are extreme, since they are sampled from conners of the n-1 simplex.

arities

The vector of arities for all nodes. By default, it is NULL.

debug

A boolean argument to display detailed steps.

Value

The returned CPTs are stored in a list that matches bnlearn CPTs format, so that the function bnlearn::rbn() can be used to sample data.


kelvinyangli/mbmml documentation built on June 29, 2020, 3:12 a.m.