dynsight.analysis.compute_kl_entropy¶
- dynsight.analysis.compute_kl_entropy(data, n_neigh=1, units='bit')[source]¶
Estimate Shannon differential entropy using Kozachenko-Leonenko.
The Kozachenko-Leonenko k-nearest neighbors method approximates differential entropy based on distances to nearest neighbors in the sample space. It’s main advantage is being parameter-free.
Deprecated since version v2025.08.27: This function is deprecated and will be removed after June 2026. Use
analysis.shannon()instead.- Parameters:
data (NDArray[np.float64]) – The dataset for which the entropy is to be computed. Shape (n_data,)
n_neigh (int) – The number of neighbors considered in the KL estimator.
units (Literal['bit', 'nat']) – The units of measure of the output entropy. If “bit”, it is computed with log base 2, if “nat” with natural log.
- Returns:
The Shannon differential entropy of the dataset, in bits.
- Return type:
Example
import numpy as np from dynsight.analysis import compute_kl_entropy np.random.seed(1234) data = np.random.rand(10000) data_entropy = compute_kl_entropy(data)