Quantum Algorithms, Quantum Computing, Physics, Mathematics, Education.
circuits backend = Aer.get_backend('qasm_simulator') job = execute(circuits, backend, shots=samples) counts = job.result().get_counts() # get expectation values, ordered the same way as the circuits expectation_vals = [] for count in counts: m = (count.get('0', 0) - count.get('1', 0)) / samples