40 lines
1.1 KiB
Plaintext
40 lines
1.1 KiB
Plaintext
---
|
||
title: purity (v0.31)
|
||
description: API reference for qiskit.quantum_info.purity in qiskit v0.31
|
||
in_page_toc_min_heading_level: 1
|
||
python_api_type: function
|
||
python_api_name: qiskit.quantum_info.purity
|
||
---
|
||
|
||
<span id="qiskit-quantum-info-purity" />
|
||
|
||
# qiskit.quantum\_info.purity
|
||
|
||
<Function id="qiskit.quantum_info.purity" isDedicatedPage={true} github="https://github.com/qiskit/qiskit/tree/stable/0.18/qiskit/quantum_info/states/measures.py" signature="purity(state, validate=True)">
|
||
Calculate the purity of a quantum state.
|
||
|
||
The purity of a density matrix $\rho$ is
|
||
|
||
$$
|
||
\text{Purity}(\rho) = Tr[\rho^2]
|
||
$$
|
||
|
||
**Parameters**
|
||
|
||
* **state** ([*Statevector*](qiskit.quantum_info.Statevector "qiskit.quantum_info.Statevector") *or*[*DensityMatrix*](qiskit.quantum_info.DensityMatrix "qiskit.quantum_info.DensityMatrix")) – a quantum state.
|
||
* **validate** (*bool*) – check if input state is valid \[Default: True]
|
||
|
||
**Returns**
|
||
|
||
the purity $Tr[\rho^2]$.
|
||
|
||
**Return type**
|
||
|
||
float
|
||
|
||
**Raises**
|
||
|
||
**QiskitError** – if the input isn’t a valid quantum state.
|
||
</Function>
|
||
|