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 -gate enables us to specify the qubit state vector angle 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, executefrom qiskit.visualization import plot_histogramimport matplotlib.pyplot as pltfrom math import asin, sqrtdef 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 priorqc.ry(prob_to_angle(0.4), 0)# execute the qcresults = execute(qc,Aer.get_backend('statevector_simulator')).result().get_counts()plot_histogram(results)
The ...