pub fn get_mutual_info(
x: &[f64],
y: &[f64],
n_bins: Option<usize>,
normalize: bool,
) -> CodependenceResult<f64>Expand description
Mutual information I[X;Y] = H[X] + H[Y] - H[X,Y] of x and y, estimated from an
n_bins x n_bins equal-width histogram.
n_bins = None uses get_optimal_number_of_bins with the sample correlation. With
normalize = true the result is divided by min(H[X], H[Y]) and lies in [0, 1]. The
histogram estimate is biased upward on small samples; compare values only at equal length
and binning. Normalised mutual information is not a distance; use
variation_of_information_score for clustering.
ยงErrors
CodependenceError::InputLengthMismatchifxandydiffer in length.CodependenceError::InputTooShortif they are empty, or (withn_bins = None) have fewer than two observations.CodependenceError::InvalidBinsifn_binsisSome(0)or the bin rule fails.CodependenceError::ZeroVarianceifn_bins = Noneand a series is constant, ornormalizeis true and either marginal entropy is zero.