entropy_pair {covalchemy} | R Documentation |
Calculate Entropy of a Pair
Description
This function calculates the entropy of a pair of variables (or a pairwise contingency table) based on the probability distribution of their joint occurrences.
Usage
entropy_pair(table)
Arguments
table |
A numeric vector or matrix. A contingency table or frequency table of a pair of variables. |
Details
The entropy is calculated using the formula: [ H(X, Y) = - sum p(x, y) * log_2(p(x, y)) ] where \( p(x, y) \) is the probability of observing the pair \( (x, y) \) from the table.
Value
A numeric value representing the entropy of the pair.
Examples
# Example usage with a simple contingency table:
pair_table <- table(c(1, 2, 2, 3), c(1, 1, 2, 2))
entropy_pair(pair_table)
[Package covalchemy version 1.0.0 Index]