polars.Series.entropy
-
Computes the entropy.
Uses the formula
-sum(pk * log(pk))wherepkare discrete probabilities.- Parameters:
-
- base
-
Given base, defaults to
e - normalize
-
Normalize pk if it doesn’t sum to 1.
Examples
>>> a = pl.Series([0.99, 0.005, 0.005]) >>> a.entropy(normalize=True) 0.06293300616044681 >>> b = pl.Series([0.65, 0.10, 0.25]) >>> b.entropy(normalize=True) 0.8568409950394724
Series.entropy(
base: float = 2.718281828459045,
*,
normalize: bool = True,
) → float | None
© 2020 Ritchie Vink
© 2022 Polars contributors
Licensed under the MIT License.
https://docs.pola.rs/api/python/stable/reference/series/api/polars.Series.entropy.html