Is it possible to see what are the values of $\alpha$ (probability of being in state zero) and $\beta$ (probability of being in state one) while running on IBM Quantum simulator (we can call it state vector).


3 Answers 3


To extract the statevector with qiskit, you can do the following:

from qiskit.aqua import QuantumInstance
from qiskit.circuit import QuantumCircuit
from qiskit import Aer, execute

qc= QuantumCircuit(2, 2)
print(qc )
quantum_instance = QuantumInstance(backend = Aer.get_backend("statevector_simulator"), shots= 1)
Result = quantum_instance.execute(qc) 
print('Statevector:', Result.get_statevector() )

q_0: ┤ H ├──■──
q_1: ─────┤ X ├
c: 2/══════════
Statevector: [0.70710678+0.j 0.        +0.j 0.        +0.j 0.70710678+0.j]
  • $\begingroup$ I don’t need to run it on quantum computer right? To simulate state vector? $\endgroup$
    – User1086
    Feb 28, 2021 at 18:17
  • $\begingroup$ statevector simulator is an ideal classical simulator. It just manipulate the linear algebra directly. $\endgroup$
    – KAJ226
    Feb 28, 2021 at 21:15

Just note that $\alpha$ and $\beta$ are not probabilities but amplitudes. A qubit is in general described as superpositon $|q\rangle = \alpha|0\rangle + \beta|1\rangle$. Probability of measuring $0$ is $|\alpha|^2$ and probability of measuring $1$ is $|\beta|^2$.

You can see both probabilities and state vector in circuit composer on IBM Q. For example assume a simple circuit described by matrix $HX$ which transforms $|0\rangle$ to $\frac{1}{\sqrt{2}}(|0\rangle - |1\rangle)$. Probability of measuring 0 and 1 is 50 % in both cases. State vector is $\frac{1}{\sqrt{2}}\begin{pmatrix} 1 & 1 \end{pmatrix}$. You can see this output in the figure below.

enter image description here


You can have access to the quantum state vector only if you're using the state_vector_simulator to run your circuit, that must be written without any measurements. Otherwise, using QASM_simulator and a circuit provided with measurements, you can access by repeating measurement (via the shots keyword) to an approximate evaluation of alpha (probability of zero outcome) and beta (probability of one outcome).

  • $\begingroup$ Than You for responding. can I able to get for this code? simulator = Aer.get_backend('qasm_simulator') circuit = QuantumCircuit(2, 2) circuit.h(0) circuit.cx(0, 1) circuit.measure([0,1], [0,1]) job = execute(circuit, simulator, shots=1000) result = job.result() counts = result.get_counts(circuit) print("\nTotal count for 00 and 11 are:",counts) $\endgroup$
    – User1086
    Feb 28, 2021 at 10:39
  • $\begingroup$ yes, "counts" is a dictionary containing your results. so counts['00']/shots is the probability of getting the 00 outcome and so on. These probabilities are the square modules of the quantum state coefficients on computational basis. The only way to access to the coefficient itselves (with complex phases) are via statevector_simulator. $\endgroup$
    – Laura
    Feb 28, 2021 at 14:44
  • $\begingroup$ Be aware that with this method you don't get alpha and beta, you get their squared moduli: $|\alpha|^2$ and $|\beta|^2$. $\endgroup$ Mar 1, 2021 at 6:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.