38 lines
1.0 KiB
Plaintext
38 lines
1.0 KiB
Plaintext
---
|
||
title: shannon_entropy (v0.31)
|
||
description: API reference for qiskit.quantum_info.shannon_entropy in qiskit v0.31
|
||
in_page_toc_min_heading_level: 1
|
||
python_api_type: function
|
||
python_api_name: qiskit.quantum_info.shannon_entropy
|
||
---
|
||
|
||
<span id="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.18/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>
|
||
|