1
$\begingroup$

I'm trying to plot the counts for the same tensor state (00, say) over many runs, but I'm not sure how to access the data from the "counts" variable in a numerical format that is usable (with matplotlib, for example) after a given run. For context, the reason I am trying to do this is that each run corresponds to a Trotter timestep for unitary time evolution, and I'm trying to plot the evolution of the 00 state over time to compare with the numerical result.

Any help is appreciated!

$\endgroup$
5
  • $\begingroup$ can you provide example code? $\endgroup$
    – poig
    Commented Jun 23, 2022 at 2:00
  • $\begingroup$ results.get_counts() returns a dictionary where each key represents a resulting state (eg. 00, 01..) and the values are the total counts for that state. Do you mean that you're trying to extract the result per run (eg. run0 => 00, run1 => 00 run2 => 11)? $\endgroup$ Commented Jun 23, 2022 at 7:33
  • $\begingroup$ @Iftachyakar Embarrassingly, I'm a Python novice and had no knowledge of the dictionary datatype. Thank you very much for your comment. $\endgroup$
    – Robert
    Commented Jun 23, 2022 at 13:44
  • $\begingroup$ @Robert I recommend you to use dir() and qiskit documentation, to see what attribute is available, and play with them. There is other more scenario of retrieve counts data, when you talk about trotter timestep. $\endgroup$
    – poig
    Commented Jun 23, 2022 at 15:23
  • $\begingroup$ Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. $\endgroup$
    – Community Bot
    Commented Jun 23, 2022 at 18:23

1 Answer 1

1
$\begingroup$

If counts is shown something like {'0': 1, '1': 14}, then to retreive the count for say 1 as 14as cnt_value_1 = counts.get('1') so that the count value is stored in variable cnt_value_1.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.