Calculating Joint Probability
Learn how we can calculate joint probability and represent two marginal probabilities with a single qubit.
We'll cover the following...
After finding the marginal probability now, we want to calculate the joint probability of two events. Both events have marginal probabilities between 0.0 and 1.0, just like any other probability.
The following figure depicts the joint probability of two variables.
Mathematically, we can calculate joint probability by multiplying both marginal probabilities. Let’s say event B has a probability of 0.8. We expect a probability of .
Let’s try it with Qiskit.
Representing two marginal probabilities with a single qubit
# Specify the marginal probabilitiesevent_a = 0.4event_b = 0.8qc = QuantumCircuit(4)# Set qubit to priorqc.ry(prob_to_angle(event_a), 0)# Apply modifierqc.ry(prob_to_angle(event_b), 0)run_circuit(qc)
This didn’t work. We’re not even close to the target probability. Instead, we get a probability of .
The problem is the calculation of the angle inside the prob_to_angle
-function. We calculate the angle as the arcsine of the target probability’s square root. Let’s look at this function. The following figure depicts the shape of ... ...