# qml.purity¶

purity(wires)[source]

The purity of the system prior to measurement.

$\gamma = \text{Tr}(\rho^2)$

where $$\rho$$ is the density matrix. The purity of a normalized quantum state satisfies $$\frac{1}{d} \leq \gamma \leq 1$$, where $$d$$ is the dimension of the Hilbert space. A pure state has a purity of 1.

Parameters

wires (Sequence[int] or int) – The wires of the subsystem

Returns

Measurement process instance

Return type

PurityMP

Example

dev = qml.device("default.mixed", wires=2)

@qml.qnode(dev)
def circuit_purity(p):

>>> circuit_purity(0.1)