...

/

Probabilities and the Qubit States

Probabilities and the Qubit States

Learn how we can rotate the qubit state and calculate the angle that represents a certain probability.

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 circuit
qc = 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 circuit
backend = Aer.get_backend('statevector_simulator')
# execute the qc
results = execute(qc,backend).result().get_counts()
# plot the results
plot_histogram(results)

The Qiskit QuantumCircuit object provides the ry function in line 13. The ry function is for RyR_y gate. Since it rotates the qubit around the y-axis of the quantum system, this function takes the angle θ\theta, in radians, as the first parameter. The value of 2*pi denotes a full rotation of ...