Search⌘ K

Calculating the Posterior Probability

Explore how to calculate posterior probabilities within a quantum naive Bayes classifier using controlled rotation gates and auxiliary qubits. Understand techniques for modifying target qubit probabilities with modifiers above and below one, and learn how to implement these calculations in parameterized quantum circuits to accurately represent posterior states.

We use the controlled RYR_Y-gate to calculate the posterior probability.

Calculating the posterior probability for a modifier smaller than 1.0

Python 3.5
for step in range(0, len(modifiers)):
if sorted_modifiers[step] > 1:
# TO BE IMPLEMENTED
pass
else:
# apply modifier to the target qubit
qc.cry(prob_to_angle(1-sorted_modifiers[step]), target, step*2)
qc.cx(step*2,target)

If the modifier is below 1.01.0 in the code block after line 6, we need to reduce the target probability by a portion of 1modifier1−modifier in line 8. The target qubit acts as the control qubit. In states when the target qubit is 1, we separate a part of 1−modifier and set the controlled qubit to 1. The controlled qubit has the index step*2. The for step is 0, and the index of this qubit is 0, too. This qubit acts as a trunk. We do not work with it anymore.

The controlled rotation does not change the value of the control qubit. Thus, the target-qubit is 1 in both parts. The following CNOT-gate in ...