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$
  • $\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 Nov 26 '20 at 17:12
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$
  • $\begingroup$ So there are no quantum circuit to doing this? $\endgroup$ – Saptarshi Sahoo Nov 26 '20 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 Nov 26 '20 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$ – Saptarshi Sahoo Nov 27 '20 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 Dec 3 '20 at 12:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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