MI.plugin: A plug-in calculator for evaluating mutual information

View source: R/information.plugin.R

MI.pluginR Documentation

A plug-in calculator for evaluating mutual information

Description

MI.plugin measures the mutual information between two random variables from the joint probability distribution table.

Usage

MI.plugin(probs, unit = c("log", "log2", "log10"))

Arguments

probs

the joint probability distribution table of two random variables.

unit

the base of the logarithm. The default is natural logarithm, which is "log". For evaluating entropy in bits, it is suggested to set the unit to "log2".

Value

MI.plugin returns the mutual information.

Examples

# two numeric vectors corresponding to two continuous random variables
x <- c(0.0, 0.2, 0.2, 0.7, 0.9, 0.9, 0.9, 0.9, 1.0)
y <- c(1.0, 2.0,  12, 8.0, 1.0, 9.0, 0.0, 3.0, 9.0)

# corresponding joint count table estimated by "uniform width" algorithm
count_xy <- discretize2D(x, y, "uniform_width")

# the joint probability distribution table of the count data
library("entropy")
probs_xy <- freqs.empirical(count_xy)

# corresponding mutual information
MI.plugin(probs_xy)

chupan1218/Informeasure documentation built on Jan. 19, 2024, 5:30 p.m.