The expectation value of an operator $A$ is defined by this equation $\langle A \rangle_\psi = \sum_j a_j |\langle \psi | \phi_j \rangle|^2 $.

My first question is does it mean that the expectation can be a negative value? If we want to calculate the observable $Z$ in the state $|1\rangle$, the expectation value is -1, right?

Suppose we have a four-qubit circuit, and we measure it using qiskit. As the measurement is done on $Z$ basis, it corresponds to calculate the expectation value of observable $ZZZZ$. Let's say the output state is $|0001\rangle$ using a simulator.

Since the eigenvalue of $|0001\rangle$ is -1, the expectation value, in this case, is -1. (Is it correct?)

When I execute the circuit on a real quantum chip with shots 1170, I get the result like: $|0000\rangle : 100$, $|0001\rangle :900 $, $|1001\rangle : 50$, $|0011\rangle : 120$.

How can I calculate the expectation value based on the results?

Is it equal to the sum of each state times its probability ($0\times\frac{100}{1170} + 1\times\frac{900}{1170}+ 9\times\frac{50}{1170} + 3\times\frac{120}{1170}$)

or the sum of state probability times its eigenvalue $(1\times100 + (-1)\times900 + 1\times50 + 1\times120)/1170$?

  • 4
    $\begingroup$ The last one. And yes, expectation values can be negative. $\endgroup$
    – DaftWullie
    May 19, 2021 at 14:19
  • $\begingroup$ @peachnuts Note that in general, to get the exact expectation, you will need to do infinite number of experiments/shots. $\endgroup$
    – KAJ226
    May 19, 2021 at 15:43