# Evaluated Standard deviation during QAOA/VQE optimization is always zero. Qiskit 0.19

I'm using qiskit 0.19.1, and I'm doing some simulation of QAOA, using the aqua class QAOA. I use a callback function in my program to see energy and std during optimization, but the evaluated standard deviation is always zero, at any step (This is clearly not true almost in the final state, that is a superposition of target Hamiltonian eigenstates). I do not figure out why, because I used this code before the release 0.19 (apart of small changes because of new libraries that in principle shoud not affect the results) and it correctly gave me a non zero std. Do any of you had the same problem or figure out why I have it? Thanks!

• Welcome to Quantum Computing SE! Is there any chance you'd have a minimum (not-)working example of code demonstrating this? – Mithrandir24601 May 11 at 23:16

if you are using Statevector simulation or the Aer Expectation Snapshot (which is enabled by default for better performance), the variance in the energy estimator is in fact zero, as the evaluation is done using matrix multiplication. If you'd prefer to perform a shot-based estimation, try setting the expectation property of your QAOA object to PauliExpectation(), where PauliExpectation is imported from qiskit.aqua.operators. Please keep in mind that this type of simulation will likely be much slower. The Aer Expectation Snapshot is an expectation value taken in C++ within Aer, so it saves a lot of resource consumption.