-
Notifications
You must be signed in to change notification settings - Fork 351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expectation value of Y and variances are wrong in SnapshotExpectationValue #895
Comments
I just found the expectaiton value of Y is correct for from qiskit import QuantumCircuit, execute, Aer
qc = QuantumCircuit(1)
qc.snapshot_expectation_value('x', [(1, 'X')], qubits=[0], variance=True)
qc.snapshot_expectation_value('y', [(1, 'Y')], qubits=[0], variance=True)
qc.snapshot_expectation_value('z', [(1, 'Z')], qubits=[0], variance=True)
result = execute(qc, Aer.get_backend('statevector_simulator')).result()
print(result.data()) the output is
I have checked this for other input states. However, variances are still zero. |
Value: I guess that there is a bug in the stabilizer simulator. In the previous execution you were probably automatically directed to the stabilizer simulator, whereas in the second execution you explicitly asked for the non-stabilizer simulator. Variance: as long as there is no noise it is expected to be 0, because we compute <psi|Y|psi> (we don't perform average of measurement results). |
Thank you for the comment. I checked about value. from qiskit import QuantumCircuit, execute, Aer
qc = QuantumCircuit(1)
qc.t(0)
qc.snapshot_expectation_value('x', [(1, 'X')], qubits=[0], variance=True)
qc.snapshot_expectation_value('y', [(1, 'Y')], qubits=[0], variance=True)
qc.snapshot_expectation_value('z', [(1, 'Z')], qubits=[0], variance=True)
result = execute(qc, Aer.get_backend('qasm_simulator')).result()
print(result.data()['snapshots']) the output is
so I obtained correct value. Your guess seems correct. For variance, we should return the population variance for (at least) the statevector simulator. |
The variance in snapshots is only the sample variance over noise for each shot of the snapshotted value: eg for 5-shots you have |
The first issue was fixed in #849 . For the second issue, I discussed with @chriseclectic , and it's good to remove the Thanks a lot. |
Informations
What is the current behavior?
The output is
Are these behaviors as expected? I'm concerned about the following points:
The text was updated successfully, but these errors were encountered: