Skip to main contentIBM Quantum Documentation
This page is from an old version of Qiskit SDK and does not exist in the latest version. We recommend you migrate to the latest version. See the release notes for more information.

shannon_entropy

shannon_entropy(pvec, base=2)

GitHub

Compute the Shannon entropy of a probability vector.

The shannon entropy of a probability vector pv is defined as $H(pv) = - sum_j pv[j] log_b (pv[j])$ where $0 log_b 0 = 0$.

Parameters

  • pvec (array_like) – a probability vector.
  • base (int) – the base of the logarithm

Returns

The Shannon entropy H(pvec).

Return type

float

Was this page helpful?
Report a bug or request content on GitHub.