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.
Important

IBM Quantum Platform is moving and this version will be sunset on July 1. To get started on the new platform, read the migration guide.

qiskit.quantum_info.shannon_entropy

shannon_entropy(pvec, base=2)

GitHub

Compute the Shannon entropy of a probability vector.

The shannon entropy of a probability vector p=[p0,...,pn1]\vec{p} = [p_0, ..., p_{n-1}] is defined as

H(p)=i=0n1pilogb(pi)H(\vec{p}) = \sum_{i=0}^{n-1} p_i \log_b(p_i)

where bb is the log base and (default 2), and 0logb(0)00 \log_b(0) \equiv 0.

Parameters

  • pvec (array_like) – a probability vector.
  • base (int) – the base of the logarithm [Default: 2].

Returns

The Shannon entropy H(pvec).

Return type

float

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