Circuit Implementation

Learn how we can implement circuits and define the CCRY-gate.

We start with implementing our example thus far, which was to determine the effect the Sex of a passenger and being a child (isChild) had on the Survival of the Titanic shipwreck.

A qubit represents each node in the Bayesian network. Since all our nodes in this dataset are presented as binary (Sex, isChild, Survival), a single qubit each will be sufficient. If we had more discrete states or a continuous distribution, we would need more qubits. The qubit states represent the marginal (for root nodes) and the conditional (for Survival node) probability amplitudes of the corresponding variables.

The state 0|0\rangle represents a male passenger or an adult. The state 1|1\rangle represents a female or a child. The superposition of the qubit denotes the probability of either state.

  • ψSex=P(male)0+P(female)1\psi_{Sex}=\sqrt{P(male)}|0\rangle+\sqrt{P(female)}|1\rangle
  • ψisChild=P(adult)0+P(child)1\psi_{isChild}=\sqrt{P(adult)}|0\rangle+\sqrt{P(child)}|1\rangle

We initialize these two qubits through rotations around the Y-axis.

Get hands-on with 1400+ tech skills courses.