Expectation Values from Circuits
Track: Quantum Gates & Circuits · Difficulty: Beginner · Est: 15 min
Expectation Values from Circuits
Overview
When you run a circuit, you typically get raw measurement samples (bitstrings). But many quantum workflows care about a different quantity:
- an expectation value like or .
This page addresses the practical problem:
- how to turn raw samples into a meaningful numeric summary of the state.
Expectation values are central because they compress many samples into a single number that can be compared, optimized, or tracked across circuit variations.
Intuition
A measurement outcome is discrete (0 or 1). An expectation value is the average value of a quantity over many shots.
In classical probability, if you flip a biased coin and record 1 for heads and 0 for tails, then:
- the average of many trials estimates the probability of heads.
In quantum measurement, we often want averages of observables like Z or X. These are “two-outcome measurements” with outcomes usually treated as or .
So the workflow is:
- run the circuit many times,
- map each measured bit to a number ( or ),
- average.
That average is the estimated expectation value.
Formal Description
Raw samples vs expectation values
- Raw samples: a list of measured outcomes, like 0, 1, 0, 0, 1.
- Expectation value: a single number summarizing the average of a measurement.
Computing conceptually
For a single qubit, measuring in the computational basis corresponds to measuring the Z observable. We use the mapping:
- outcome 0 corresponds to eigenvalue
- outcome 1 corresponds to eigenvalue
If you take shots and obtain outcomes with , define
Then the estimated expectation value is
Interpretation:
- if you see mostly 0 outcomes, is near +1,
- if you see mostly 1 outcomes, is near −1,
- if outcomes are balanced, it is near 0.
Computing conceptually
To measure X, you measure in the X basis. A practical way to do this using standard computational-basis measurement is:
- apply H before measurement,
- then measure in the computational basis.
This works because H maps the X basis to the Z basis. So:
- “measure X” can be implemented as “apply H, then measure Z.”
Then you use the same mapping and average.
We’re not doing heavy operator math here. The key idea is: change basis, then sample, then average.
Worked Example
Suppose you run a single-qubit circuit and measure in the computational basis. You take shots and get:
0, 0, 1, 0, 1, 0, 0, 0Counts:
- six 0 outcomes
- two 1 outcomes
Convert to values:
- each 0 contributes +1
- each 1 contributes −1
So the sum is . The average is
Interpretation:
- the circuit produced a state biased toward in the Z basis,
- but not perfectly; an expectation value of 0.5 is between +1 and 0.
Turtle Tip
To compute an expectation value from shots: map outcomes to numbers, then average. Histograms are great for intuition, but expectation values are often what algorithms actually consume.
Common Pitfalls
- Don’t average raw bits (0/1) when you mean . Use the mapping.
- Don’t forget basis: computational-basis measurement naturally gives Z information. To estimate X, you must effectively measure in the X basis (for example via a basis-change gate).
Quick Check
- If all shots return 0, what is ?
- Conceptually, how can you measure X using only computational-basis measurement?
What’s Next
Expectation values are one way quantum computation outputs a useful number. Next we discuss the broader picture: quantum computation is typically hybrid. After measurement, classical post-processing turns samples and expectation values into decisions, updates, and final results.
