# Simulating Measurement in Python

In this lesson, we look at measuring qubits and reading the results of our quantum computations.

We'll cover the following

In this chapter, we started by creating quantum states and gates in NumPy. We then put those together and saw how one could apply gates to single and multi-qubit systems. Finally, in this lesson, we shall complete this computation puzzle and measure the state of our quantum system.

## Measurement under the hood

Recall that measurement takes qubits to the computational basis states $|0\rangle$ and $|1\rangle$. Intuitively, this meant that we were transferring information of the qubit state in a classical register whose value we could read. Mathematically, this process is defined as taking the inner product of an arbitrary state $|\phi\rangle$ with the conjugate transpose of the $|x\rangle$, which is the state we want to measure $|\psi\rangle$ in:

$p(|x\rangle)=|\langle x|\phi\rangle|^2$

This operation is easily implemented in NumPy. The code below shows the probability of measuring state $|\phi\rangle=\frac{1}{\sqrt{2}}|0\rangle-\frac{i}{\sqrt{2}}|1\rangle$ in the state $|1\rangle$.

Get hands-on with 1200+ tech skills courses.