# Finding the Exact Probability Distribution for the Outcomes of a Quantum Circuit with Mid-Circuit Measurements

I would like to find the exact probabilities of the possible outcomes of a circuit that includes mid-circuit measurements.

So, as a specific example, consider the following circuit:

I would like to find the exact probabilities for all possible outcomes in the classical register (so no sampling). Does anyone have any idea of how to do that? The typical route of using Statevector from qiskit.quantum_info doesn't work here, because it can only deal with the final state of the qubits.

For clarity: I am working in qiskit, but I am happy to switch to whatever language this is possible in.

• According to the Deferred Measurement Principle all measurements can be delayed until the end of quantum computation and this will not change the probability distribution of outcomes. The circuit that you posted is epic and I feel like it deserves to become a meme. I suggest reading the basic info about the gate $H$ and measurements before programming anything. Jul 21 at 8:45
• Thanks for your comment. I understand that you could in principle defer measurements, simply by introducing an ancilla qubit and a CNOT. I'd rather not do that though because the circuits I am actually looking at have many mid-circuit measurements, so I would need an infeasible number of ancillas. What I was trying to get is a simulator that would propagate the density matrix of the system, and then apply a dephasing channel when mid-circuit measurements are applied, all while remembering the outcome probabilities of the mid-circuit measurements. Do you know if qiskit supports that? Jul 21 at 18:22
• Deferring a measurement does not require CNOT or ancilla qubits. It means you can put all measurement gates at the end of computation. Jul 21 at 19:48
• How would you defer measurement in the example circuit above? Surely you would have to introduce another qubit to 'hold' the information of the mid circuit state, so you can measure them at the end? Jul 21 at 21:41
• Jul 21 at 23:58