0
$\begingroup$

In the given circuit below :

q = QuantumRegister(2,'q')

c = ClassicalRegister(2,'c')

qc = QuantumCircuit(q,c)

qc.h(0)

qc.h(1) qc.measure([0,1],[0,1])

backend = BasicAer.get_backend('qasm_simulator') job = execute(qc, backend, shots=100)

counts = job.result().get_counts()

How to predict the number of counts?

$\endgroup$

1 Answer 1

0
$\begingroup$
q = QuantumRegister(2,'q')

You have two qubits which are initialized in $|00\rangle$ state.

qc.h(0) & qc.h(1) means you are applying the Hadamard gate on both qubits.

Hence your resultant state will be $$|00\rangle \rightarrow \frac{1}{2} (|00\rangle+|01\rangle+|10\rangle+|11\rangle)$$

So upon $Z$-measurement, you have an equal probability of getting any of the {00,01,10,11} bitstrings. Hence your counts should be approximately equal.

Therefore,

backend = BasicAer.get_backend('qasm_simulator') job = execute(qc, backend, shots=100)

For the 100 shots you are measuring, you should get approximately 25 shots per bitstring.

You can predict the outcome without running the code by just performing vector-matrix multiplication, i.e. multiplying your initial state vector with the matrix representation of the circuit you are running.

$\endgroup$

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.