Learn R Programming

gRain (version 0.3.0)

cpt: Create conditional probability tables (CPTs)

Description

Creates conditional probability tables of the form p(v|pa(v)).

Usage

cpt(v, pa = NULL, values = NULL, gmData=NULL, normalize = TRUE, smooth = 0, levels=NULL)
cptspec(x)

Arguments

v
Variable
pa
Possible parents
gmData
Name of gmData object (where to look for v and pa)
values
Probabilities; recycled if necessary
normalize
See 'details' below.
smooth
See 'details' below.
levels
See 'details' below.
x
A list of cpts

Value

  • If a gmData object is given, then 'cpt' returns an object of class 'ctab' (which is a general representation of a table). If no gmData object is given, then 'cpt' returns an object of class 'cptTemplate'. 'cptspec' returns an object of class 'cptspec' (which is just a list with a special class attribute).

Details

If normalize=TRUE then for each configuration of the parents, "pa", the probabilities are normalized to sum to one. If smooth is non--zero then zero entries of values are replaced with smooth before normalization takes place. If no gmData object is given, then levels (giving the levels of 'v') must be given. Otherwise levels is ignored.

See Also

ctab

Examples

Run this code
g <- newgmData(letters[1:5],nLevels=2)

t1 <- cpt("a",pa="b", gmData=g,values=1:4)

t2 <- cpt("a",pa=c("b","c"), levels=c("y","n"),values=1:4)

Run the code above in your browser using DataLab