MoTBFs (version 1.4.1)

probDiscreteVariable: Probability distribution of discrete variables

Description

Compute the probabilities of a discrete variable from a dataset.

Usage

probDiscreteVariable(stateNames, Variable)

Arguments

stateNames

A "character" array indicating the states of the variable.

Variable

A "numeric" array containing the records of the variable.

Value

A list of "numeric" arrays:

coeff

Contains the probabilities.

sizeDataLeaf

Number of records in each leaf of the discrete tree.

See Also

discreteVariablesStates

Examples

Run this code
# NOT RUN {
## Discrete Variable
data <- data.frame(X=rep(c("yes", "no", "maybe"), 500))
data <- discreteVariables_as.character(data, "X")
n <- nrow(data)

## Probabilities
s <- discreteVariablesStates(namevariables="X", discreteData=data)
states <- s[[1]]$states
p <- probDiscreteVariable(stateNames=states, Variable=data$X)
p

# }

Run the code above in your browser using DataLab