...

/

Composing Quantum Computing Controls

Composing Quantum Computing Controls

Learn the concepts of marginal probability, joint probability, X-gate, and CRY-gate.

The QBN we’re going to build will consist of some advanced transformation gates. Let’s look at how we can create such gates.

Quantum transformation gates allow us to work with qubits. The RYR_Y-gate enables us to specify the qubit state vector angle θ\theta that controls the probability of measuring the qubit as either 0 or 1. We used it to let a qubit represent the marginal probability of surviving the Titanic shipwreck.

Specifying the marginal probability

Press + to interact
from qiskit import QuantumCircuit, Aer, execute
from qiskit.visualization import plot_histogram
import matplotlib.pyplot as plt
from math import asin, sqrt
def prob_to_angle(prob):
"""
Converts a given P(psi) value into an equivalent theta value.
"""
return 2*asin(sqrt(prob))
qc = QuantumCircuit(1)
# Set qubit to prior
qc.ry(prob_to_angle(0.4), 0)
# execute the qc
results = execute(qc,Aer.get_backend('statevector_simulator')).result().get_counts()
plot_histogram(results)

The X ...