1

I wasn't quite sure where to post this as I don't know if this is a Qiskit specific thing or not, but I'm not sure how to interpret this result I got from running a simulation.

from result.data():

{'counts': {'0x0': 371, '0x1': 653},
 'statevector': [[0.6095190950364658, 0.00167238253077826],
  [0.6389605613454776, 0.46926856185163585],
  [0.0002864410240029574, -0.00010852146395313456]]}

From result.get_statevector():

array([6.09519095e-01+1.67238253e-03j, 6.38960561e-01+4.69268562e-01j,
       2.86441024e-04-1.08521464e-04j])

This is a 1-qubit system btw

Also, I'm pretty new to QC, so pls be nice

Here's the code I'm using to simulate the system:

backend_sim = FakeArmonk()
custom_gate = Gate('custom_gate', 1, [])
qc1 = QuantumCircuit(1, 1)
qc1.initialize([np.cos(a[0]/2), np.exp(a[1]*1.j)*np.sin(a[0]/2)], 0)
qc1.append(custom_gate, [0])
qc1.measure(0, 0)
with pulse.build(backend_sim, name='custom_gate') as my_schedule:
    pulse.play(Gaussian(duration=256+64, amp=.36, sigma=80), pulse.drive_channel(0))
    qc1.add_calibration(custom_gate, [0], my_schedule)

qc1 = transpile(qc1, backend_sim) pulse_sched = schedule(qc1, backend_sim) pulse_sched.draw() job1 = execute(pulse_sched, backend_sim, shots=1024) result1 = job1.result() result1.data()

The initialize state doesn't matter, it is a random pure state, and the parameters of the Gaussian pulse are also arbitrary

3yakuya
  • 632
  • 3
  • 10
soravoid
  • 81
  • 4

1 Answers1

-1

From Qiskit docs:

Statevector backends return a dictionary with key ‘statevector’ and values being a list[list[complex components]] list of 2^num_qubits complex amplitudes. Where each complex number is represented as a 2 entry list for each component. For example, a list of [0.5+1j, 0-1j] would be represented as [[0.5, 1], [0, -1]].

which gets perhaps a bit clearer in your result from get_statevector(), where you just got an array of 3 complex values. As for why 3 and not 2, docs on Statevector dimensions can be helpful:

the length of the input vector specifies the total dimension of the density matrix. If it is a power of two the state will be initialized as an N-qubit state. If it is not a power of two the state will have a single d-dimensional subsystem.

In other words, the resulting state is a mixed state (not pure.)

Possibly helpful post on mixed states

3yakuya
  • 632
  • 3
  • 10
  • That's good to know! Tbh I didn't think a single qubit system could be mixed, but my perception of mixed and pure states are probably still off. Do you know of a way to get the density matrix out of the simulator (FakeArmonk)? Trying to get a density matrix from that statevector gives a 3x3 matrix. My ultimate goal is to check the fidelity of the final state with a pure state. – soravoid Dec 20 '21 at 00:22
  • 1
    A single qubit state can be mixed, but even then the density matrix would be 2x2. I suspect that in this case, the statevector contains not only the amplitudes for the |0> and |1> state, but also for the |2> state. On a real system, the higher energy levels are also populated a bit and since you're working with pulses it might return also higher excited states? – Cryoris Dec 20 '21 at 15:13
  • I think you're right, the numbers seem to be matching up, though the question now is whether I calculate the fidelity by excluding the probabilities in the |2> state or by making the coefficient 0 for |2> in the pure state – soravoid Dec 20 '21 at 18:14