jensen_shannon_divergence#
- infomeasure.jensen_shannon_divergence(*data, approach: str | None = None, **kwargs)[source]#
Calculate the Jensen-Shannon Divergence between two or more distributions.
The Jensen-Shannon Divergence is a symmetrized and smoothed version of the Kullback-Leibler Divergence. It is calculated as the average of the Kullback-Leibler Divergence between each distribution and the average distribution.
\[JSD(P \| Q) = \frac{1}{2} KL(P \| M) + \frac{1}{2} KL(Q \| M)\]where \(M = \frac{1}{2} (P + Q)\).
- Parameters:
- parray_like
The first data.
- qarray_like
The second data.
- …array_like
Further data to compare.
- approach
str The name of the entropy estimator to use.
- **kwargs
dict Additional keyword arguments to pass to the entropy estimator.
- Returns:
floatThe Jensen-Shannon Divergence.
- Raises:
ValueErrorIf the approach is not supported or the entropy estimator is not compatible with the Jensen-Shannon Divergence.
ValueErrorIf any of the given data is not an array-like object.