A state vector is an indexed lookup table
For n qubits, the vector has 2ⁿ entries. Each index corresponds to a basis bitstring. For two qubits, the entries correspond to |00⟩, |01⟩, |10⟩, and |11⟩ if your ordering is documented.
state = np.array([0.5+0j, 0.5j, -0.5+0j, 0.5j])
probabilities = np.abs(state) ** 2
for bits, amplitude, probability in zip(
['00', '01', '10', '11'], state, probabilities
):
print(bits, amplitude, probability)
An amplitude can be negative or complex; a probability cannot. Use pᵢ = |αᵢ|², and check that probabilities sum to one.
Phase is invisible—until it is not
(|0⟩ + |1⟩)/√2 and (|0⟩ − |1⟩)/√2 both measure 50/50 in the computational basis. Apply H and the difference becomes visible: one returns zero with certainty, the other one.
Make the picture useful
A histogram is for measurement outcomes. Real and imaginary bar charts are for debugging. A phase-aware plot is for interference. Choose the visualization that answers your question.
2ⁿ, the norm is one, probabilities are non-negative, and basis ordering is explicit.The lab code panel uses the same state-vector idea. Next, see how to apply a gate without allocating a full matrix.