Probability of each computational basis state.

This measurement function accepts no observables, and instead instructs the QNode to return a flat array containing the probabilities \(|\langle i | \psi \rangle |^2\) of measuring the computational basis state \(| i \rangle\) given the current state \(| \psi \rangle\).

Marginal probabilities may also be requested by restricting the wires to a subset of the full system; the size of the returned array will be [2**len(wires)].


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

def circuit():
    return qml.probs(wires=[0, 1])

Executing this QNode:

>>> circuit()
array([0.5, 0.5, 0. , 0. ])

The returned array is in lexicographic order, so corresponds to a \(50\%\) chance of measuring either \(|00\rangle\) or \(|01\rangle\).


wires (Sequence[int] or int) – the wire the operation acts on