...

/

Calculating Joint Probability

Calculating Joint Probability

Learn how we can calculate joint probability and represent two marginal probabilities with a single qubit.

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 0.40.8=0.320.4*0.8=0.32.

Let’s try it with Qiskit.

Representing two marginal probabilities with a single qubit

Press + to interact
# Specify the marginal probabilities
event_a = 0.4
event_b = 0.8
qc = QuantumCircuit(4)
# Set qubit to prior
qc.ry(prob_to_angle(event_a), 0)
# Apply modifier
qc.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 0.9520.952.

The problem is the calculation of the angle θ\theta 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 f(x)=arcsin(x)f(x)=arcsin(\sqrt{x}) ... ...

Access this course and 1400+ top-rated courses and projects.