Skip to content
This repository has been archived by the owner on Jun 12, 2023. It is now read-only.

Convention for expectation_counts #558

Open
zlatko-minev opened this issue Feb 19, 2021 · 0 comments
Open

Convention for expectation_counts #558

zlatko-minev opened this issue Feb 19, 2021 · 0 comments
Labels
documentation Something is not clear or error in description

Comments

@zlatko-minev
Copy link

Is the convention in the docstring backwards for
https://qiskit.org/documentation/stubs/qiskit.ignis.verification.expectation_counts.html#qiskit.ignis.verification.expectation_counts ?

It seems that the Pauli of q0 is left-most, not right-most as I read in the docs?

This is what I see as the output of

import pandas as pd 
from qiskit import *
from qiskit.ignis.verification import expectation_counts, marginal_counts

qc = QuantumCircuit(2)
qc.x(0)
qc.measure_all()
job = execute(qc, simulator_ideal, shots=1000)
counts = job.result().get_counts()

display(qc.draw(output='mpl'))

total = sum(counts.values())
expects = expectation_counts(counts) 
expects = {k.replace('0', 'I').replace('1', 'Z'): v/total for k,v in expects.items()}
pd.Series(expects)

returns

II    1.0
ZI   -1.0
IZ    1.0
ZZ   -1.0

for
image

image

@zlatko-minev zlatko-minev added the documentation Something is not clear or error in description label Feb 19, 2021
@zlatko-minev zlatko-minev changed the title Convention in Convention for expectation_counts Feb 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Something is not clear or error in description
Projects
None yet
Development

No branches or pull requests

1 participant