1
$\begingroup$

I'm trying to simulate quantum experiments using a customized noise model. Here's my code:

probabilities[0] = [0.9, 0.15]
probabilities[1] = [0.1, 0.85]
readout_noise_model = NoiseModel()
readout_noise_model.add_readout_error(probabilities[0], [0])
readout_noise_model.add_readout_error(probabilities[1], [0])

However, as I run the code, it returns me

--> 259         num_outcomes = len(probabilities[0])
    260         num_qubits = int(np.log2(num_outcomes))
    261         if 2**num_qubits != num_outcomes:

TypeError: object of type 'float' has no len()

I don't know why this happens since I could find len(probabilities[0])=2. How can I set up the noise model for readout errors? Thanks so much for the help!

$\endgroup$
1
  • 1
    $\begingroup$ It might help if you could provide more of your code (ideally a minimal standalone example to reproduce the error). The error seems to be related to the object type of probabilities but your code doesn't show how that variable is declared. $\endgroup$
    – forky40
    Commented Nov 12, 2021 at 19:45

1 Answer 1

2
$\begingroup$

According to the link that you provide in the first sentence of the question, you should write a single line

readout_noise_model.add_readout_error(probabilities, [0])
$\endgroup$
1
  • $\begingroup$ Thank you! That works! $\endgroup$
    – ZR-
    Commented Nov 13, 2021 at 22:15

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.