I would like to find density matrix after the measurement. The toy code:
import qiskit from qiskit.quantum_info import DensityMatrix circuit = qiskit.QuantumCircuit(1, 1) print(DensityMatrix.from_instruction(circuit)) circuit.measure(0, 0) print(DensityMatrix.from_instruction(circuit))
results in the following error on the second
QiskitError: 'Cannot apply instruction with classical bits: measure'
How can I make it work? As I understand, being well-defined (and taking classical probabilities into account) after the measurement is exactly the advantage of the density matrix over the state vector.
I do know how to use
save_density_matrix, and it indeed works. However, it only produces empirical results. E.g. when the true entry is 1/2, it might instead print 0.496.
It's more or less my first day working with qiskit and hearing about density matrix, so sorry if the question doesn't make sense. Ideally, I want to have the following information: a list of possible state vectors in the current state, with corresponding probabilities. As I understand, the density matrix is the closest alternative.