entropy_pair | R Documentation |
This function calculates the entropy of a pair of variables (or a pairwise contingency table) based on the probability distribution of their joint occurrences.
entropy_pair(table)
table |
A numeric vector or matrix. A contingency table or frequency table of a pair of variables. |
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.
A numeric value representing the entropy of the pair.
# Example usage with a simple contingency table:
pair_table <- table(c(1, 2, 2, 3), c(1, 1, 2, 2))
entropy_pair(pair_table)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.