0
$\begingroup$

I'm using Qiskit and after running the circuit, as we all know, we get a count dictionary such as

{'0000': 66,
 '0001': 71,
 '0010': 68,
 '0011': 70,
 '0100': 77,
 '0101': 64,
 '0110': 64,
 '0111': 51,
 '1000': 52,
 '1001': 67,
 '1010': 43,
 '1011': 64,
 '1100': 61,
 '1101': 59,
 '1110': 73,
 '1111': 74} 

Here the minimum count is 1010:43. I want the same output just reversed [1024-(count)]. I know this can be achieved by few lines of python, but I was curious if this is possible to do with a quantum circuit?

$\endgroup$
1
  • $\begingroup$ The get_counts() methods returns the count of shots that have that particular output. Are you asking for a get_counts_did_not_match? What's your use case in which shots - count is more informative? It can be a feature request in Qiskit... $\endgroup$
    – luciano
    Commented Nov 26, 2020 at 17:12

1 Answer 1

2
$\begingroup$

There is no a way in Qiskit to get the results in that format. So, you will have to go for the pure Python way:

counts = {'0000': 66, '0001': 71, '0010': 68, '0011': 70,
          '0100': 77, '0101': 64, '0110': 64, '0111': 51,
          '1000': 52, '1001': 67, '1010': 43, '1011': 64,
          '1100': 61, '1101': 59, '1110': 73, '1111': 74} 

shots = 1024
counts = { k:(shots-v) for k,v in counts.items()}
$\endgroup$
4
  • $\begingroup$ So there are no quantum circuit to doing this? $\endgroup$ Commented Nov 26, 2020 at 20:21
  • $\begingroup$ Those numbers (the values in the dict) are the amount of shots that landed in each result. Are you trying to invert the frequency of the results? I'm not sure what you mean by "a quantum circuit that does this". $\endgroup$
    – luciano
    Commented Nov 26, 2020 at 21:35
  • $\begingroup$ What i'm saying is that, that the dict is directly proportional to probability distribution of the final state , i want to know if there is a quantum way to inverse the probability distribution, low becomes high and high becomes low? $\endgroup$ Commented Nov 27, 2020 at 9:43
  • $\begingroup$ Hmm... not sure if that's possible. I might be fully wrong here. Here is my reasoning: Imposible results (with count 0) would turn into fully certain results. There are infinite amount of impossible results (for example, there is an implicit '00100': 0). What's the count those impossible results should have? Even if possible, that operation is fully classical. So probably no need to do it on the circuit. $\endgroup$
    – luciano
    Commented Dec 3, 2020 at 12:37

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.