# How to obtain the noise of a circuit in Qiskit?

I referred to the following Qiskit's document: state_fidelity.

The inputs of state_fidelity are quantum state vectors or density matrices. For example, $$|00\rangle$$ or $$|0\rangle \langle0|$$.

Now, let me assume a circuit is described as follows. The above circuit with no noise provides $$\frac{1}{\sqrt{2}}( |00\rangle + |11\rangle )$$ .

When I would like to measure the noise of this circuit, I use state_fidelity and compare the measurements and $$\frac{1}{\sqrt{2}}( |00\rangle + |11\rangle )$$. Here, we have to obtain the state vector such as numpy.array([***]).

However, I received the following error: AerError: 'statevector_simulator does not support noise.' when I set backend = Aer.get_backend('statevector_simulator')  to get the state vectors.

When I use qasm_simulator with noise_model (cf. How can noise on a device be simulated using measured noise parameters?), I obtained the following error: 'No statevector for experiment "None". However, I could obtain the counts by result().get_counts.

How can I obtain the state vector with noise_model? Do I have to calculate the state vector from the counts?

I append the code as below.

%matplotlib inline
# Importing standard Qiskit libraries and configuring account
from qiskit import QuantumCircuit, execute, Aer, IBMQ
from qiskit.compiler import transpile, assemble
from qiskit.tools.jupyter import *
from qiskit.visualization import *

from qiskit.aqua import run_algorithm
from qiskit.aqua.input import LinearSystemInput
from qiskit.quantum_info import state_fidelity
from qiskit.aqua.algorithms.classical import ExactLSsolver

from qiskit import *
import numpy as np

from qiskit.providers.aer import noise
properties = device.properties()
noise_model = noise.device.basic_device_noise_model(properties)
basis_gates = noise_model.basis_gates

def test():
q = QuantumRegister(2)
c = ClassicalRegister(2)
qc = QuantumCircuit(q,c)
qc.h( q )
qc.cx( q, q )

qc.measure(q,c)

return qc
# test().draw()

def test2():
q = QuantumRegister(2)
c = ClassicalRegister(2)
qc = QuantumCircuit(q,c)
qc.h( q )
qc.cx( q, q )

#     qc.measure(q,c)

return qc
# test2().draw()
backend = Aer.get_backend('qasm_simulator')
simulator = Aer.get_backend( 'qasm_simulator' )
job1 = execute( test(), backend, noise_model = noise_model, basis_gates= basis_gates, shots = 100 ).result().get_statevector()

backend = Aer.get_backend('statevector_simulator')
simulator = Aer.get_backend( 'statevector_simulator' )
job2 = execute( test2(), backend, noise_model=noise_model, shots = 100 ).result().get_statevector()



Thank you.

There is, however, an alternative method which skips using the simulator altogether. You can use qiskit-terra's quantum_info library to directly obtain the quantum operator for the circuit, and compose it with a quantum operator for the noise. This requires a little more understanding of the underlying math, but the results are precise, as opposed to using state tomography which is intended for "real world" use, where you don't have a noise model.