Probabilities and the Qubit States
Learn how we can rotate the qubit state and calculate the angle that represents a certain probability.
We'll cover the following...
Let’s look at our transformation in action.
Rotating the qubit state
Press + to interact
from math import pi# Define state |0>initial_state = [1, 0]# Redefine the quantum circuitqc = QuantumCircuit(1)# Initialise the 0th qubit in the state `initial_state`qc.initialize(initial_state, 0)# Rotate the state by a quarter of a half circle.qc.ry(pi/4,0)# Tell Qiskit how to simulate our circuitbackend = Aer.get_backend('statevector_simulator')# execute the qcresults = execute(qc,backend).result().get_counts()# plot the resultsplot_histogram(results)
The Qiskit QuantumCircuit
object provides the ry
function in line 13. The ry
function is for gate. Since it rotates the qubit around the y-axis of the quantum system, this function takes the angle , in radians, as the first parameter. The value of 2*pi
denotes a full rotation of ...