Skip to content

Instantly share code, notes, and snippets.

View pdc-quantum's full-sized avatar

Pierre Decoodt pdc-quantum

  • Université Libre de Bruxelles
  • Belgium
View GitHub Profile
@pdc-quantum
pdc-quantum / four_general_byzantine_agreement.py
Last active May 4, 2022 15:15
four-general_statevector.py
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
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()
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
@pdc-quantum
pdc-quantum / 001_demo.py
Last active January 11, 2022 14:41
Bayesian vs Frequentist Statistical Model for Randomized Benchmarking
import numpy as np
# settings:
qubits = [0,1]
lengths = np.arange(1, 260, 28)
num_samples = 20
seed = None
# additional information:
system = 'ibmq_manila'
@pdc-quantum
pdc-quantum / 00H_demo.py
Last active January 11, 2022 14:42
Bayesian vs Frequentist Statistical Model for Randomized Benchmarking
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="--")
@pdc-quantum
pdc-quantum / 00G_demo.py
Last active January 12, 2022 13:19
Bayesian vs Frequentist Statistical Model for Randomized Benchmarking
with h_model:
az_summary = az.summary(trace_h_model, round_to = 12,
var_names = ["π", "EPC"],
kind = "stats")
az_summary
@pdc-quantum
pdc-quantum / 00F_demo.py
Last active January 11, 2022 14:43
Bayesian vs Frequentist Statistical Model for Randomized Benchmarking
with h_model:
az.plot_posterior(trace_h_model, var_names = ["θ"],
round_to = 4, figsize = [16, 12]);
@pdc-quantum
pdc-quantum / 00E_demo.py
Last active January 11, 2022 14:43
Bayesian vs Frequentist Statistical Model for Randomized Benchmarking
with h_model:
az.plot_posterior(trace_h_model, var_names = ["σ_Beta"],
round_to = 4, figsize = [16, 12]);
@pdc-quantum
pdc-quantum / 00D_demo.py
Last active January 12, 2022 12:59
Posterior tying parameters
with h_model:
az.plot_posterior(trace_h_model, var_names = ["π"],
round_to = 4, figsize = [15, 3]);
@pdc-quantum
pdc-quantum / 00C_demo.py
Last active January 11, 2022 14:44
Bayesian vs Frequentist Statistical Model for Randomized Benchmarking
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);