This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from qiskit import QuantumCircuit | |
# define the state vector | |
init_list = np.array( [0., 0., 0., 0., 0., 0., 0., 6.**.5, | |
0., +1., +1., 0., +1., 0., 0., 0., | |
0., 0., 0., +1., 0., +1., +1., 0., | |
6.**.5, 0., 0., 0., 0., 0., 0., 0.]) / np.sqrt(18) | |
# create the circuit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from qiskit import execute | |
from qiskit.providers.aer import AerSimulator | |
from qiskit.test.mock import FakeSantiago | |
from qiskit.tools.visualization import plot_histogram | |
device_backend = FakeSantiago() | |
sim_backend= AerSimulator.from_backend(device_backend) | |
job = execute(circuit, backend = sim_backend, shots = 8192, | |
optimization_level = 2) | |
counts_noise = job.result().get_counts() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from qiskit import QuantumCircuit | |
init_list = np.array([0., 0., 0., 2., 0., -1., -1., 0., | |
0., -1., -1., 0., 2., 0., 0., 0.]) / ( 2*np.sqrt(3) ) | |
circuit = QuantumCircuit(4) | |
circuit.initialize(init_list, circuit.qubits) | |
# add Pauli-Z measurements and draw the circuit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
# settings: | |
qubits = [0,1] | |
lengths = np.arange(1, 260, 28) | |
num_samples = 20 | |
seed = None | |
# additional information: | |
system = 'ibmq_manila' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
with h_model: | |
az.plot_posterior(trace_h_model, var_names = ["EPC"], | |
round_to = 4, figsize = [10,6], textsize = 12) | |
Bayes_legend = "EPC Bayesian: {0:1.3e} ± {1:1.3e}"\ | |
.format(az_summary['mean']['EPC'], az_summary['sd']['EPC']) | |
LSF_legend = "EPC Frequentist: {0:1.3e} ± {1:1.3e}"\ | |
.format(epc_est, epc_est_err) | |
plt.axvline(x=az_summary['mean']['EPC'], color='blue', ls="--") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with h_model: | |
az_summary = az.summary(trace_h_model, round_to = 12, | |
var_names = ["π", "EPC"], | |
kind = "stats") | |
az_summary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with h_model: | |
az.plot_posterior(trace_h_model, var_names = ["θ"], | |
round_to = 4, figsize = [16, 12]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with h_model: | |
az.plot_posterior(trace_h_model, var_names = ["σ_Beta"], | |
round_to = 4, figsize = [16, 12]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with h_model: | |
az.plot_posterior(trace_h_model, var_names = ["π"], | |
round_to = 4, figsize = [15, 3]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with h_model: | |
trace_h_model = pm.sample(draws = 2000, tune = 500, target_accept = .95, | |
return_inferencedata = True, chains = 4) | |
az.plot_trace(trace_h_model); |
NewerOlder