Skip to content

Commit

Permalink
adding colored noise and biased detector updates
Browse files Browse the repository at this point in the history
  • Loading branch information
bdoolittle committed Sep 12, 2022
1 parent cc0fa49 commit e7cf430
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 42 deletions.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions script/plots/detector_biased_noise_robustness.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@
],
plot_dir="./data/plots/detector_biased_noise_robustness/",
legend_labels=["Arbitrary VQO", "Max Entangled VQO"],
ncol_legend=2,
bottom_padding=0.45,
fig_height=7,
ncol_legend=4,
bottom_padding=0.3,
fig_height=5,
)
48 changes: 28 additions & 20 deletions script/plots/source_colored_noise_robustness.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,52 +430,60 @@ def verify_data(theoretical_score, vqo_score, atol=1e-8):
return theoretical_score >= vqo_score or np.isclose(theoretical_score, vqo_score, atol=atol)

for u in range(21):
assert verify_data(phi_plus_theoretical_chsh, phi_plus_max_chsh_colored)
assert verify_data(phi_plus_theoretical_single_bilocal, phi_plus_max_bilocal_single_colored)
assert verify_data(phi_plus_theoretical_chsh[5 * u], phi_plus_max_chsh_colored[u])
assert verify_data(
phi_plus_theoretical_single_n3_chain, phi_plus_max_bilocal_single_colored
phi_plus_theoretical_single_bilocal[5 * u], phi_plus_max_bilocal_single_colored[u]
)
assert verify_data(
phi_plus_theoretical_single_n4_chain, phi_plus_max_n4_chain_single_colored
phi_plus_theoretical_single_n3_chain[5 * u], phi_plus_max_n3_chain_single_colored[u]
)
assert verify_data(
phi_plus_theoretical_single_n4_chain[5 * u], phi_plus_max_n4_chain_single_colored[u]
)
assert verify_data(
phi_plus_theoretical_single_n3_star[5 * u], phi_plus_max_n3_star_single_colored[u]
)
assert verify_data(phi_plus_theoretical_single_n3_star, phi_plus_max_n3_star_single_colored)

assert verify_data(psi_plus_theoretical_chsh, psi_plus_max_chsh_colored)
assert verify_data(psi_plus_theoretical_single_bilocal, psi_plus_max_bilocal_single_colored)
assert verify_data(psi_plus_theoretical_chsh[5 * u], psi_plus_max_chsh_colored[u])
assert verify_data(
psi_plus_theoretical_single_bilocal[5 * u], psi_plus_max_bilocal_single_colored[u]
)
assert verify_data(
psi_plus_theoretical_single_n3_chain[5 * u], psi_plus_max_n3_chain_single_colored[u]
)
assert verify_data(
psi_plus_theoretical_single_n3_chain, psi_plus_max_bilocal_single_colored
psi_plus_theoretical_single_n4_chain[5 * u], psi_plus_max_n4_chain_single_colored[u]
)
assert verify_data(
psi_plus_theoretical_single_n4_chain, psi_plus_max_n4_chain_single_colored
psi_plus_theoretical_single_n3_star[5 * u], psi_plus_max_n3_star_single_colored[u]
)
assert verify_data(psi_plus_theoretical_single_n3_star, psi_plus_max_n3_star_single_colored)

assert verify_data(phi_plus_theoretical_chsh, phi_plus_max_chsh_colored)
assert verify_data(phi_plus_theoretical_chsh[5 * u], phi_plus_max_chsh_colored[u])
assert verify_data(
phi_plus_theoretical_uniform_bilocal, phi_plus_max_bilocal_uniform_colored
phi_plus_theoretical_uniform_bilocal[5 * u], phi_plus_max_bilocal_uniform_colored[u]
)
assert verify_data(
phi_plus_theoretical_uniform_n3_chain, phi_plus_max_bilocal_uniform_colored
phi_plus_theoretical_uniform_n3_chain[5 * u], phi_plus_max_n3_chain_uniform_colored[u]
)
assert verify_data(
phi_plus_theoretical_uniform_n4_chain, phi_plus_max_n4_chain_uniform_colored
phi_plus_theoretical_uniform_n4_chain[5 * u], phi_plus_max_n4_chain_uniform_colored[u]
)
assert verify_data(
phi_plus_theoretical_uniform_n3_star, phi_plus_max_n3_star_uniform_colored
phi_plus_theoretical_uniform_n3_star[5 * u], phi_plus_max_n3_star_uniform_colored[u]
)

assert verify_data(psi_plus_theoretical_chsh, psi_plus_max_chsh_colored)
assert verify_data(psi_plus_theoretical_chsh[5 * u], psi_plus_max_chsh_colored[u])
assert verify_data(
psi_plus_theoretical_uniform_bilocal, psi_plus_max_bilocal_uniform_colored
psi_plus_theoretical_uniform_bilocal[5 * u], psi_plus_max_bilocal_uniform_colored[u]
)
assert verify_data(
psi_plus_theoretical_uniform_n3_chain, psi_plus_max_bilocal_uniform_colored
psi_plus_theoretical_uniform_n3_chain[5 * u], psi_plus_max_n3_chain_uniform_colored[u]
)
assert verify_data(
psi_plus_theoretical_uniform_n4_chain, psi_plus_max_n4_chain_uniform_colored
psi_plus_theoretical_uniform_n4_chain[5 * u], psi_plus_max_n4_chain_uniform_colored[u]
)
assert verify_data(
psi_plus_theoretical_uniform_n3_star, psi_plus_max_n3_star_uniform_colored
psi_plus_theoretical_uniform_n3_star[5 * u], psi_plus_max_n3_star_uniform_colored[u]
)

"""
Expand Down
36 changes: 18 additions & 18 deletions script/plots/source_depolarizing_noise_robustness.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ def bell_state_noise(gamma):
if __name__ == "__main__":
num_samples = 21

theory_noise_params = np.arange(0, 1.0001, 0.001)

bell_state_noise_states = [bell_state_noise(gamma) for gamma in np.arange(0, 1.01, 0.05)]

bell_state = np.array([[1, 0, 0, 1], [0, 0, 0, 0], [0, 0, 0, 0], [1, 0, 0, 1]]) / 2
Expand Down Expand Up @@ -55,7 +57,7 @@ def bell_state_noise(gamma):
# ]

theoretical_max_chsh = [
np.sqrt(2) * np.abs((1 - gamma * 16 / 15)) for gamma in np.arange(0, 1.01, 0.05)
np.sqrt(2) * np.abs((1 - gamma * 16 / 15)) for gamma in theory_noise_params
]

"""
Expand Down Expand Up @@ -103,12 +105,11 @@ def bell_state_noise(gamma):
# ]

theoretical_max_uniform_bilocal = [
np.sqrt(2) * np.sqrt(np.abs((1 - gamma * 16 / 15) ** 2))
for gamma in np.arange(0, 1.01, 0.05)
np.sqrt(2) * np.sqrt(np.abs((1 - gamma * 16 / 15) ** 2)) for gamma in theory_noise_params
]

theoretical_max_single_bilocal = [
np.sqrt(2) * np.sqrt(np.abs((1 - gamma * 16 / 15))) for gamma in np.arange(0, 1.01, 0.05)
np.sqrt(2) * np.sqrt(np.abs((1 - gamma * 16 / 15))) for gamma in theory_noise_params
]

"""
Expand Down Expand Up @@ -152,12 +153,11 @@ def bell_state_noise(gamma):
# ]

theoretical_max_uniform_n3_chain = [
np.sqrt(2) * np.sqrt(np.abs((1 - gamma * 16 / 15) ** 3))
for gamma in np.arange(0, 1.01, 0.05)
np.sqrt(2) * np.sqrt(np.abs((1 - gamma * 16 / 15) ** 3)) for gamma in theory_noise_params
]

theoretical_max_single_n3_chain = [
np.sqrt(2) * np.sqrt(np.abs((1 - gamma * 16 / 15))) for gamma in np.arange(0, 1.01, 0.05)
np.sqrt(2) * np.sqrt(np.abs((1 - gamma * 16 / 15))) for gamma in theory_noise_params
]

"""
Expand Down Expand Up @@ -201,13 +201,12 @@ def bell_state_noise(gamma):
# ]

theoretical_max_single_n3_star = [
np.sqrt(2) * np.power(np.abs((1 - gamma * 16 / 15)), 1 / 3)
for gamma in np.arange(0, 1.01, 0.05)
np.sqrt(2) * np.power(np.abs((1 - gamma * 16 / 15)), 1 / 3) for gamma in theory_noise_params
]

theoretical_max_uniform_n3_star = [
np.sqrt(2) * np.power(np.abs((1 - gamma * 16 / 15) ** 3), 1 / 3)
for gamma in np.arange(0, 1.01, 0.05)
for gamma in theory_noise_params
]

"""
Expand All @@ -218,15 +217,15 @@ def verify_data(theoretical_score, vqo_score):
return theoretical_score >= vqo_score or np.isclose(theoretical_score, vqo_score)

for u in range(21):
assert verify_data(theoretical_max_chsh[u], max_chsh_dep[u])
assert verify_data(theoretical_max_uniform_bilocal[u], max_bilocal_uniform_dep[u])
assert verify_data(theoretical_max_uniform_n3_chain[u], max_n3_chain_uniform_dep[u])
assert verify_data(theoretical_max_uniform_n3_star[u], max_n3_star_uniform_dep[u])
assert verify_data(theoretical_max_chsh[50 * u], max_chsh_dep[u])
assert verify_data(theoretical_max_uniform_bilocal[50 * u], max_bilocal_uniform_dep[u])
assert verify_data(theoretical_max_uniform_n3_chain[50 * u], max_n3_chain_uniform_dep[u])
assert verify_data(theoretical_max_uniform_n3_star[50 * u], max_n3_star_uniform_dep[u])

assert verify_data(theoretical_max_chsh[u], max_chsh_dep[u])
assert verify_data(theoretical_max_single_bilocal[u], max_bilocal_single_dep[u])
assert verify_data(theoretical_max_single_n3_chain[u], max_n3_chain_single_dep[u])
assert verify_data(theoretical_max_single_n3_star[u], max_n3_star_single_dep[u])
assert verify_data(theoretical_max_chsh[50 * u], max_chsh_dep[u])
assert verify_data(theoretical_max_single_bilocal[50 * u], max_bilocal_single_dep[u])
assert verify_data(theoretical_max_single_n3_chain[50 * u], max_n3_chain_single_dep[u])
assert verify_data(theoretical_max_single_n3_star[50 * u], max_n3_star_single_dep[u])

"""
Plotting Data
Expand Down Expand Up @@ -268,4 +267,5 @@ def verify_data(theoretical_score, vqo_score):
plot_dir="./data/plots/source_depolarizing_noise_robustness/",
# bottom_padding=0.4,
ncol_legend=3,
theory_params=theory_noise_params,
)
9 changes: 8 additions & 1 deletion src/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,7 @@ def plot_unital_single_and_uniform_max_scores_data(
bottom_padding=0.3,
fig_height=5,
ncol_legend=4,
theory_params=[],
):
"""Plots the noise robustness for single and uniform qubit/source/measurement
noise models. This method is intended for plotting the max score across many
Expand Down Expand Up @@ -637,6 +638,9 @@ def plot_unital_single_and_uniform_max_scores_data(
:param plot_dir: The directory to which the data will be plotted.
:type plt_dir: String
:param theory_params: Noise params for theoretical data.
:type theory_params: List
"""
fig, axes = plt.subplots(1, 2, figsize=(10, fig_height))
fig.suptitle(fig_title, fontsize=24, fontweight="bold")
Expand All @@ -655,6 +659,9 @@ def plot_unital_single_and_uniform_max_scores_data(
# line_widths = [5.5,5,4.5,4,3.5,3,2.5,2]
dashes_list = [2, 3, 4, 5, 6, 7, 8, 9]

if len(theory_params) == 0:
theory_params = noise_params

ax_data_sets = [single_max_scores, uniform_max_scores]
ax_theory_sets = [single_theoretical_scores, uniform_theoretical_scores]
ax_match_sets = [single_match_scores, uniform_match_scores]
Expand Down Expand Up @@ -692,7 +699,7 @@ def plot_unital_single_and_uniform_max_scores_data(

if len(theory_set) != 0:
(theory_plt,) = ax.plot(
noise_params,
theory_params,
theory_set,
color=line_colors[j],
linestyle=":",
Expand Down

0 comments on commit e7cf430

Please sign in to comment.