Lesson 3 of 15

Measurement

The Born Rule

When we measure a qubit, the superposition collapses to either 0angle|0 angle or 1angle|1 angle. The probabilities are given by the Born rule:

  • P(0angle)=alpha2P(|0 angle) = |alpha|^2
  • P(|1 angle) = |eta|^2

For the 0angle|0 angle state [1.0, 0.0]: P(0)=1P(0) = 1, P(1)=0P(1) = 0 — certain outcome.

For the equal superposition left[ rac{1}{sqrt{2}}, rac{1}{sqrt{2}} ight]: P(0)=0.5P(0) = 0.5, P(1)=0.5P(1) = 0.5 — truly random.

import math

def prob_zero(state):
    return state[0] ** 2

def prob_one(state):
    return state[1] ** 2

s = 1 / math.sqrt(2)
superposition = [s, s]

print(round(prob_zero(superposition), 4))  # 0.5
print(round(prob_one(superposition), 4))   # 0.5

After measurement, the qubit is irreversibly in the measured state — the superposition is gone.

Your Task

Implement prob_zero(state) and prob_one(state) using the Born rule.

Python runtime loading...
Loading...
Click "Run" to execute your code.