probDiscreteVariable: Probability distribution of discrete variables
Description
Compute the probabilities of a discrete variable from a data set using Laplace correction.
Usage
probDiscreteVariable(x)
Value
A list of 2 elements:
coeff
a named vector that contains the probabilities.
sizeDataLeaf
a vector containing the number of records in each leaf of the discrete tree.
Arguments
x
a "factor" containing the records of the discrete variable.
Details
Laplace correction is used to avoid the zero probability problem, with \(\alpha = 1\) as smoothing factor.
Therefore, the probability for each state, \(\theta_i\), is computed as
$$\theta_i = \frac{x_i + 1}{N + K}$$
for \(i = 0, 1, \ldots, K\),
where \(x_i\) is the number of records of state \(i\),
\(N\) is the total number of records, and
\(K\) is the total number of states.