From 36e9a1aa9398facfaaa324f7a163efe2ec046796 Mon Sep 17 00:00:00 2001 From: Joshua Coles Date: Fri, 17 Mar 2023 15:36:50 +0000 Subject: [PATCH] sp-fd figures --- notebooks/sp-fd-rust-vs-c.py | 71 ++++++++++++++++++++++++++++++++++++ notebooks/sp-fd.py | 2 +- 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 notebooks/sp-fd-rust-vs-c.py diff --git a/notebooks/sp-fd-rust-vs-c.py b/notebooks/sp-fd-rust-vs-c.py new file mode 100644 index 0000000..9e60a25 --- /dev/null +++ b/notebooks/sp-fd-rust-vs-c.py @@ -0,0 +1,71 @@ +import numpy as np +from matplotlib import pyplot as plt + +from notebooks.lib import read_sp + + +def process_sp(sp): + by_run = sp.groupby(['probability', 'N']) + + by_probability = by_run.agg( + overall_fd=('fd', lambda fd: np.mean(fd[-100:])), + overall_fd_std=('fd', 'std') + ).reset_index().groupby('probability') + + ggg = by_probability.agg( + fd=('overall_fd', 'mean'), + # TODO Check stats, do we need to do /sqrt(n) here? + fd_std=('overall_fd_std', lambda std: np.sqrt(np.mean(np.square(std)))) + ) + + return ggg + + +c_sp = read_sp("../data/stick-probability") +rust_sp = read_sp("../data/rust-sticking-probability") + +# %% +c_data = process_sp(c_sp) +rust_data = process_sp(rust_sp) + +# %% + +# plt.fill_between( +# c_data.index, +# c_data.fd - c_data.fd_std, +# c_data.fd + c_data.fd_std, +# alpha=0.2, +# color='tab:blue', +# label=f"IPC + PS, Standard error band" +# ) + +plt.plot( + c_data.index, + c_data.fd, + color='tab:blue', + label='IPC + PS, fd mean, seeds = 100' +) + +# plt.fill_between( +# rust_data.index, +# rust_data.fd - rust_data.fd_std, +# rust_data.fd + rust_data.fd_std, +# alpha=0.2, +# color='tab:orange', +# label=f"NF, Standard error band" +# ) + +plt.plot( + rust_data.index, + rust_data.fd, + color='tab:orange', + label='NF, fd mean, seeds = 100' +) + +plt.xlabel("$p_{stick}$") +plt.ylabel("$fd$") +plt.legend() + +plt.savefig('../figures/sp-fd-rust-vs-c.svg') +plt.savefig('../figures/sp-fd-rust-vs-c.png') +plt.show() diff --git a/notebooks/sp-fd.py b/notebooks/sp-fd.py index 12f2907..fa04c10 100644 --- a/notebooks/sp-fd.py +++ b/notebooks/sp-fd.py @@ -17,9 +17,9 @@ ggg = by_probability.agg( fd_std=('overall_fd_std', lambda std: np.sqrt(np.mean(np.square(std)))) ) +# %% plt.fill_between(ggg.index, ggg.fd - ggg.fd_std, ggg.fd + ggg.fd_std, alpha=0.2, label=f"Standard error band") plt.plot(ggg.index, ggg.fd, color='tab:blue', label='fd mean, seeds = 100') -plt.plot(ggg.index, ggg.fd) plt.xlabel("$p_{stick}$") plt.ylabel("$fd$")