from qiskit import *
import numpy as np
%matplotlib inline

qc = QuantumCircuit(1,1)
qc.s(0)
qc.measure(0,0,basis='X')
backend = BasicAer.get_backend('dm_simulator')
run = execute(qc,backend)
result = run.result()
result['results'][0]['data']['densitymatrix']

qc1 = QuantumCircuit(1,1)
qc1.s(0)
qc1.measure(0,0, basis='N', add_param=np.array([1,2,3]))         
backend = BasicAer.get_backend('dm_simulator')
run1 = execute(qc1,backend)
result1 = run1.result()
result1['results'][0]['data']['densitymatrix']

qc2 = QuantumCircuit(3,2)
qc2.measure(0,0,basis='Bell',add_param='01')
options2 = {
    'plot': True
}
backend = BasicAer.get_backend('dm_simulator')
run2 = execute(qc2,backend,**options2)
result2 = run2.result()
result2['results'][0]['data']['bell_probabilities01']

qc3 = QuantumCircuit(3,3)
qc3.h(0)
qc3.cx(0,1)
qc3.cx(1,2)
qc3.measure(0,0,basis='Ensemble',add_param='X')
backend = BasicAer.get_backend('dm_simulator')
options3 = {
    'plot': True
}
run3 = execute(qc3,backend,**options3)
result3 = run3.result()
result3['results'][0]['data']['ensemble_probability']

qc4 = QuantumCircuit(3,3)
qc4.h(0)
qc4.cx(0,1)
qc4.cx(1,2)
qc4.measure(0,0,basis='Expect',add_param='ZIZ')
backend = BasicAer.get_backend('dm_simulator')
run4 = execute(qc4,backend)
result4 = run4.result()
result4['results'][0]['data']['Pauli_string_expectation']