79611653

Date: 2025-05-08 02:53:26
Score: 1
Natty:
Report link

Turns out the answer was very simple, I needed to pass the index of the qubit to probabilities_dict rather than the qubit directly.

The last 2 lines should be changed to:

# marginal probability of flag==1 must equal P[x ≥ deductible]
# index of the single‑qubit flag register inside *this* circuit
flag_index = qc.qubits.index(flag[0])

p_excess = sv.probabilities_dict(qargs=[flag_index])['1']
print(f"P(loss ≥ 1) = {p_excess:.4f}")
Reasons:
  • Blacklisted phrase (0.5): I need
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Alex F