In order to calculate the exact expectation value of a Pauli operator in some state using local qasm_simulator
, I do
psi = qiskit.aqua.operators.state_fns.CircuitStateFn( circuit )
expect = psi.adjoint().compose( weighted_pauli.to_opflow() ).compose( psi ).eval().real
I would like to run this calculation using ibmq_quantum_simulator
. In all the examples I found online (see e.g. this one), ibmq_quantum_simulator
is used to simulate sampling with some number of shots. How do I use it with shots = None
, similarly to the code above?
shots=None
to get the expectation value, this doesn't really make much sense; there are two ways to do the calculation of the expectation value: the exact way (the code you put) or with shot-based sampling, meaning using the simulator. I strongly advise you to look at this answer, quantumcomputing.stackexchange.com/questions/12080/…, really well-written about how to calculate the expectation value with Qiskit. As you can see the simulator is used for the second way of calculation. $\endgroup$ibmq_quantum_simulator
? $\endgroup$ibmq_qasm_simulator
samples from the exact probability distribution, which is probably calculated using the statevector representation. I was hoping I can access it, but I don't know if it is possible... $\endgroup$imbq_qasm_simulator
is similar to that ofqasm_simulator
. And inqasm_simulator
one can choosemethod = statevector
. $\endgroup$