Add 3D sp graph
This commit is contained in:
parent
efcd6c0099
commit
1155064306
BIN
figures/sp-fd-3d.png
Normal file
BIN
figures/sp-fd-3d.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 27 KiB |
1146
figures/sp-fd-3d.svg
Normal file
1146
figures/sp-fd-3d.svg
Normal file
File diff suppressed because it is too large
Load Diff
|
After Width: | Height: | Size: 27 KiB |
@ -6,7 +6,7 @@
|
||||
<rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
||||
<cc:Work>
|
||||
<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
|
||||
<dc:date>2023-03-17T21:12:53.560959</dc:date>
|
||||
<dc:date>2023-03-17T21:40:06.539395</dc:date>
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:creator>
|
||||
<cc:Agent>
|
||||
@ -241,18 +241,18 @@ L 80.391405 85.275263
|
||||
L 77.112066 68.875397
|
||||
L 73.832727 53.568
|
||||
z
|
||||
" clip-path="url(#pfe185082f7)" style="fill: #1f77b4; fill-opacity: 0.2"/>
|
||||
" clip-path="url(#p910af6b5dd)" style="fill: #1f77b4; fill-opacity: 0.2"/>
|
||||
</g>
|
||||
<g id="matplotlib.axis_1">
|
||||
<g id="xtick_1">
|
||||
<g id="line2d_1">
|
||||
<defs>
|
||||
<path id="mdd114e1862" d="M 0 0
|
||||
<path id="m60a6ddb271" d="M 0 0
|
||||
L 0 3.5
|
||||
" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</defs>
|
||||
<g>
|
||||
<use xlink:href="#mdd114e1862" x="70.553388" y="307.584" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
<use xlink:href="#m60a6ddb271" x="70.553388" y="307.584" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_1">
|
||||
@ -297,7 +297,7 @@ z
|
||||
<g id="xtick_2">
|
||||
<g id="line2d_2">
|
||||
<g>
|
||||
<use xlink:href="#mdd114e1862" x="136.140165" y="307.584" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
<use xlink:href="#m60a6ddb271" x="136.140165" y="307.584" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_2">
|
||||
@ -338,7 +338,7 @@ z
|
||||
<g id="xtick_3">
|
||||
<g id="line2d_3">
|
||||
<g>
|
||||
<use xlink:href="#mdd114e1862" x="201.726942" y="307.584" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
<use xlink:href="#m60a6ddb271" x="201.726942" y="307.584" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_3">
|
||||
@ -374,7 +374,7 @@ z
|
||||
<g id="xtick_4">
|
||||
<g id="line2d_4">
|
||||
<g>
|
||||
<use xlink:href="#mdd114e1862" x="267.313719" y="307.584" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
<use xlink:href="#m60a6ddb271" x="267.313719" y="307.584" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_4">
|
||||
@ -421,7 +421,7 @@ z
|
||||
<g id="xtick_5">
|
||||
<g id="line2d_5">
|
||||
<g>
|
||||
<use xlink:href="#mdd114e1862" x="332.900496" y="307.584" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
<use xlink:href="#m60a6ddb271" x="332.900496" y="307.584" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_5">
|
||||
@ -477,7 +477,7 @@ z
|
||||
<g id="xtick_6">
|
||||
<g id="line2d_6">
|
||||
<g>
|
||||
<use xlink:href="#mdd114e1862" x="398.487273" y="307.584" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
<use xlink:href="#m60a6ddb271" x="398.487273" y="307.584" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_6">
|
||||
@ -663,12 +663,12 @@ z
|
||||
<g id="ytick_1">
|
||||
<g id="line2d_7">
|
||||
<defs>
|
||||
<path id="me3e3fbf5f8" d="M 0 0
|
||||
<path id="m0a91ddf3df" d="M 0 0
|
||||
L -3.5 0
|
||||
" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</defs>
|
||||
<g>
|
||||
<use xlink:href="#me3e3fbf5f8" x="57.6" y="277.987127" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
<use xlink:href="#m0a91ddf3df" x="57.6" y="277.987127" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_8">
|
||||
@ -695,7 +695,7 @@ z
|
||||
<g id="ytick_2">
|
||||
<g id="line2d_8">
|
||||
<g>
|
||||
<use xlink:href="#me3e3fbf5f8" x="57.6" y="224.082766" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
<use xlink:href="#m0a91ddf3df" x="57.6" y="224.082766" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_9">
|
||||
@ -710,7 +710,7 @@ z
|
||||
<g id="ytick_3">
|
||||
<g id="line2d_9">
|
||||
<g>
|
||||
<use xlink:href="#me3e3fbf5f8" x="57.6" y="170.178406" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
<use xlink:href="#m0a91ddf3df" x="57.6" y="170.178406" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_10">
|
||||
@ -757,7 +757,7 @@ z
|
||||
<g id="ytick_4">
|
||||
<g id="line2d_10">
|
||||
<g>
|
||||
<use xlink:href="#me3e3fbf5f8" x="57.6" y="116.274045" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
<use xlink:href="#m0a91ddf3df" x="57.6" y="116.274045" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_11">
|
||||
@ -772,7 +772,7 @@ z
|
||||
<g id="ytick_5">
|
||||
<g id="line2d_11">
|
||||
<g>
|
||||
<use xlink:href="#me3e3fbf5f8" x="57.6" y="62.369685" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
<use xlink:href="#m0a91ddf3df" x="57.6" y="62.369685" style="stroke: #000000; stroke-width: 0.8"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="text_12">
|
||||
@ -948,7 +948,7 @@ L 388.649256 264.966605
|
||||
L 391.928595 266.435894
|
||||
L 395.207934 269.009223
|
||||
L 398.487273 267.63711
|
||||
" clip-path="url(#pfe185082f7)" style="fill: none; stroke: #1f77b4; stroke-width: 1.5; stroke-linecap: square"/>
|
||||
" clip-path="url(#p910af6b5dd)" style="fill: none; stroke: #1f77b4; stroke-width: 1.5; stroke-linecap: square"/>
|
||||
</g>
|
||||
<g id="patch_3">
|
||||
<path d="M 57.6 307.584
|
||||
@ -1379,7 +1379,7 @@ z
|
||||
</g>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="pfe185082f7">
|
||||
<clipPath id="p910af6b5dd">
|
||||
<rect x="57.6" y="41.472" width="357.12" height="266.112"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
|
||||
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
@ -68,6 +68,16 @@ def read_load(load_dir: str, reader=read_xy_alt):
|
||||
return pd.concat([reader(path) for path in paths])
|
||||
|
||||
|
||||
def augment_read_with_sp(inner_reader):
|
||||
def hoc(path: str):
|
||||
probability = float(Path(path).parent.name)
|
||||
df = inner_reader(path)
|
||||
df['probability'] = probability
|
||||
return df
|
||||
|
||||
return hoc
|
||||
|
||||
|
||||
def read_sp_xy(specific_probability_dir: str):
|
||||
probability = float(Path(specific_probability_dir).name)
|
||||
df = read_load(specific_probability_dir)
|
||||
@ -76,11 +86,16 @@ def read_sp_xy(specific_probability_dir: str):
|
||||
return df
|
||||
|
||||
|
||||
def read_sp(sp_dir: str):
|
||||
def read_sp(sp_dir: str, inner_reader=read_xy_alt):
|
||||
if not Path(sp_dir).exists():
|
||||
raise Exception("Root does not exist")
|
||||
|
||||
return pd.concat([read_sp_xy(specific_probability_dir) for specific_probability_dir in glob(f'{sp_dir}/*')])
|
||||
reader = augment_read_with_sp(inner_reader)
|
||||
|
||||
return pd.concat([
|
||||
read_load(specific_probability_dir, reader)
|
||||
for specific_probability_dir in glob(f'{sp_dir}/*')
|
||||
])
|
||||
|
||||
|
||||
def convergent_tail_index(series, tol):
|
||||
@ -126,3 +141,20 @@ def mean_across(df):
|
||||
.replace([np.inf, -np.inf], np.nan)
|
||||
|
||||
return data
|
||||
|
||||
|
||||
def aggregate_sp_fd(df):
|
||||
by_run = df.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')
|
||||
|
||||
data = by_probability.agg(
|
||||
fd=('overall_fd', 'mean'),
|
||||
# TODO Check stats
|
||||
fd_std=('overall_fd_std', lambda std: np.sqrt(np.mean(np.square(std))))
|
||||
)
|
||||
|
||||
return data
|
||||
|
||||
18
notebooks/sp-fd-3d.py
Normal file
18
notebooks/sp-fd-3d.py
Normal file
@ -0,0 +1,18 @@
|
||||
from matplotlib import pyplot as plt
|
||||
|
||||
from notebooks.lib import read_sp, read_xyz_alt, aggregate_sp_fd
|
||||
|
||||
data_3d_sp = read_sp("../data/rust-3d-offaxis-sp", read_xyz_alt)
|
||||
sp_fd_data = aggregate_sp_fd(data_3d_sp)
|
||||
|
||||
# %%
|
||||
plt.fill_between(sp_fd_data.index, sp_fd_data.fd - sp_fd_data.fd_std, sp_fd_data.fd + sp_fd_data.fd_std, alpha=0.2, label=f"Standard error band")
|
||||
plt.plot(sp_fd_data.index, sp_fd_data.fd, color='tab:blue', label='fd mean, seeds = 100')
|
||||
|
||||
plt.xlabel("$p_{stick}$")
|
||||
plt.ylabel("$fd$")
|
||||
plt.legend()
|
||||
|
||||
plt.savefig('../figures/sp-fd-3d.svg')
|
||||
plt.savefig('../figures/sp-fd-3d.png')
|
||||
plt.show()
|
||||
@ -1,25 +1,13 @@
|
||||
import numpy as np
|
||||
from matplotlib import pyplot as plt
|
||||
|
||||
from notebooks.lib import read_sp
|
||||
from notebooks.lib import read_sp, aggregate_sp_fd
|
||||
|
||||
c_sp = read_sp("../data/stick-probability")
|
||||
by_run = c_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
|
||||
fd_std=('overall_fd_std', lambda std: np.sqrt(np.mean(np.square(std))))
|
||||
)
|
||||
data_2d_sp = read_sp("../data/stick-probability")
|
||||
sp_fd_data = aggregate_sp_fd(data_2d_sp)
|
||||
|
||||
# %%
|
||||
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.fill_between(sp_fd_data.index, sp_fd_data.fd - sp_fd_data.fd_std, sp_fd_data.fd + sp_fd_data.fd_std, alpha=0.2, label=f"Standard error band")
|
||||
plt.plot(sp_fd_data.index, sp_fd_data.fd, color='tab:blue', label='fd mean, seeds = 100')
|
||||
|
||||
plt.xlabel("$p_{stick}$")
|
||||
plt.ylabel("$fd$")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user