I have a code of 10 qubits. How to know the probability of each qubit?
The code is:
for idx, px_value in enumerate(phi[::-1]):
measurement = [qml.expval(qml.PauliZ(i)) for i in range(wires)]
I want to return both probability and measurement. How to do that also?
To return the probability of each qubit (10 in your case), you can return
qml.probs(wires=range(10)). In addition, QNodes can return multiple measurements. Consider this code example:
dev = qml.device("lightning.qubit", wires=2)
return qml.probs(wires=range(2)), qml.expval(qml.PauliX(0))
# Output: (tensor([0.5, 0.5, 0. , 0. ], requires_grad=True), tensor(1., requires_grad=True))
All of the available measurements and use cases can be found here.
Let me know if that helps!