Skip to content

Commit

Permalink
Update RB example to work with the current version
Browse files Browse the repository at this point in the history
  • Loading branch information
thangleiter committed Feb 19, 2020
1 parent 0c70e55 commit 165d22e
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions examples/randomized_benchmarking.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,17 @@ def run_randomized_benchmarking(N_G: int, N_l: int, min_l: int, max_l: int,
H_n = {}
H_c = {}
dt = {}
H_c['Id'] = [[qt.sigmax().full(), [0]]]
H_n['Id'] = [[qt.sigmax().full(), [1]],
[qt.sigmay().full(), [1]]]
H_c['Id'] = [[qt.sigmax().full(), [0], 'X']]
H_n['Id'] = [[qt.sigmax().full(), [1], 'X'],
[qt.sigmay().full(), [1], 'Y']]
dt['Id'] = [T]
H_c['X2'] = [[qt.sigmax().full(), [np.pi/4/T]]]
H_n['X2'] = [[qt.sigmax().full(), [1]],
[qt.sigmay().full(), [1]]]
H_c['X2'] = [[qt.sigmax().full(), [np.pi/4/T], 'X']]
H_n['X2'] = [[qt.sigmax().full(), [1], 'X'],
[qt.sigmay().full(), [1], 'Y']]
dt['X2'] = [T]
H_c['Y2'] = [[qt.sigmay().full(), [np.pi/4/T]]]
H_n['Y2'] = [[qt.sigmax().full(), [1]],
[qt.sigmay().full(), [1]]]
H_c['Y2'] = [[qt.sigmay().full(), [np.pi/4/T], 'Y']]
H_n['Y2'] = [[qt.sigmax().full(), [1], 'X'],
[qt.sigmay().full(), [1], 'Y']]
dt['Y2'] = [T]

# %% Set up PulseSequences
Expand Down Expand Up @@ -169,7 +169,7 @@ def run_randomized_benchmarking(N_G: int, N_l: int, min_l: int, max_l: int,
# Scaling factor for the noise so that alpha = 0 and alpha = 0.7 have the same
# power
noise_scaling_factor = {
0.0: 0.39651222009884685,
0.0: 0.4415924985735799,
0.7: 1
}

Expand Down Expand Up @@ -200,16 +200,16 @@ def run_randomized_benchmarking(N_G: int, N_l: int, min_l: int, max_l: int,
for i, alpha in enumerate((0.0, 0.7)):

means = np.mean(fidelities[alpha], axis=1)
errs = np.std(fidelities[alpha], axis=1)/np.sqrt(N_G)
stds = np.std(fidelities[alpha], axis=1)

popt, pcov = optimize.curve_fit(fitfun, lengths, means, [0, 1], errs,
popt, pcov = optimize.curve_fit(fitfun, lengths, means, [0, 1], stds,
absolute_sigma=True)

for j in range(N_G):
fid = ax[i].plot(lengths, fidelities[alpha][:, j], 'k.', alpha=0.1,
zorder=2)

mean = ax[i].errorbar(lengths, means, errs, fmt='.', zorder=3,
mean = ax[i].errorbar(lengths, means, stds, fmt='.', zorder=3,
color='tab:red')
fit = ax[i].plot(lengths, fitfun(lengths, *popt), '--', zorder=4,
color='tab:red')
Expand Down

0 comments on commit 165d22e

Please sign in to comment.