qiskit-documentation/docs/api/qiskit/0.27/qiskit.quantum_info.shannon...

36 lines
971 B
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: shannon_entropy
description: API reference for qiskit.quantum_info.shannon_entropy
in_page_toc_min_heading_level: 1
python_api_type: function
python_api_name: qiskit.quantum_info.shannon_entropy
---
# qiskit.quantum\_info.shannon\_entropy
<Function id="qiskit.quantum_info.shannon_entropy" isDedicatedPage={true} github="https://github.com/qiskit/qiskit/tree/stable/0.17/qiskit/quantum_info/states/utils.py" signature="shannon_entropy(pvec, base=2)">
Compute the Shannon entropy of a probability vector.
The shannon entropy of a probability vector $\vec{p} = [p_0, ..., p_{n-1}]$ is defined as
$$
H(\vec{p}) = \sum_{i=0}^{n-1} p_i \log_b(p_i)
$$
where $b$ is the log base and (default 2), and $0 \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
</Function>