Stash
This commit is contained in:
parent
bf2df8a897
commit
a56f3158cb
BIN
c-3d-off-axis-neighbours
Executable file
BIN
c-3d-off-axis-neighbours
Executable file
Binary file not shown.
603
notebooks/3d.ipynb
Normal file
603
notebooks/3d.ipynb
Normal file
File diff suppressed because one or more lines are too long
7724
notebooks/alpha.ipynb
Normal file
7724
notebooks/alpha.ipynb
Normal file
File diff suppressed because one or more lines are too long
BIN
notebooks/fig1.png
Normal file
BIN
notebooks/fig1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 29 KiB |
23275
notebooks/fig1.svg
Normal file
23275
notebooks/fig1.svg
Normal file
File diff suppressed because it is too large
Load Diff
|
After Width: | Height: | Size: 563 KiB |
69
notebooks/lib.py
Normal file
69
notebooks/lib.py
Normal file
@ -0,0 +1,69 @@
|
||||
import os
|
||||
from glob import glob
|
||||
from pathlib import Path
|
||||
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
|
||||
|
||||
def read_xy(path: str):
|
||||
df = pd.read_csv(path, skipinitialspace=True)
|
||||
df['N'] = df.index + 1
|
||||
df['r'] = (df.x ** 2 + df.y ** 2) ** 0.5
|
||||
df['cr'] = df.r.cummax()
|
||||
df['fd'] = np.log(df.N) / np.log(df.cr)
|
||||
df['run'] = os.path.splitext(Path(path).name)[0]
|
||||
|
||||
return df.replace([np.inf, -np.inf], np.nan).dropna()
|
||||
|
||||
|
||||
def read_load(load_dir: str, reader=read_xy):
|
||||
paths = glob(f'{load_dir}/*.csv')
|
||||
return pd.concat([reader(path) for path in paths])
|
||||
|
||||
|
||||
def read_sp_xy(specific_probability_dir: str):
|
||||
probability = float(Path(specific_probability_dir).name)
|
||||
df = read_load(specific_probability_dir)
|
||||
df['probability'] = probability
|
||||
|
||||
return df
|
||||
|
||||
|
||||
def read_sp(sp_dir: str):
|
||||
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}/*')])
|
||||
|
||||
|
||||
def convergent_tail_index(series, tol):
|
||||
diffs = np.abs(np.ediff1d(series))
|
||||
for i in range(0, len(diffs)):
|
||||
if np.max(diffs[i:]) <= tol:
|
||||
return i
|
||||
|
||||
# No convergence found
|
||||
return None
|
||||
|
||||
|
||||
def mean_of_tail(series, tol=0.05):
|
||||
tail_index = convergent_tail_index(series, tol)
|
||||
if tail_index is None:
|
||||
raise Exception("No convergence found.")
|
||||
|
||||
return np.mean(series[tail_index:])
|
||||
|
||||
|
||||
def std_of_tail(series, tol=0.05):
|
||||
tail_index = convergent_tail_index(series, tol)
|
||||
if tail_index is None:
|
||||
raise Exception("No convergence found.")
|
||||
|
||||
return np.std(series[tail_index:])
|
||||
|
||||
|
||||
def fd_stats(dfs):
|
||||
fds = [mean_of_tail(df.fd, 0.1) for df in dfs]
|
||||
fds_clean = [f for f in fds if f < np.inf]
|
||||
return np.mean(fds_clean), np.mean(fds_clean) / np.sqrt(fds_clean.length())
|
||||
36
notebooks/nc-fd-convergence.py
Normal file
36
notebooks/nc-fd-convergence.py
Normal file
@ -0,0 +1,36 @@
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
from notebooks.lib import read_load
|
||||
|
||||
alpha = read_load("../data/alpha")
|
||||
meaned_by_N = alpha.groupby('N').agg({'fd': ['mean', 'std']}) \
|
||||
.reset_index() \
|
||||
.replace([np.inf, -np.inf], np.nan)
|
||||
|
||||
without_prefix = meaned_by_N[50:]
|
||||
fig, ax = plt.subplots(figsize=(6, 6))
|
||||
|
||||
plt.fill_between(
|
||||
without_prefix.N,
|
||||
# TODO Check error math here
|
||||
(without_prefix['fd']['mean'] - without_prefix['fd']['std'] / np.sqrt(20)),
|
||||
(without_prefix['fd']['mean'] + without_prefix['fd']['std'] / np.sqrt(20)),
|
||||
alpha=0.2, label=f"Standard error band"
|
||||
)
|
||||
|
||||
plt.plot(
|
||||
without_prefix.N,
|
||||
without_prefix['fd']['mean'],
|
||||
color='tab:blue', label='fd mean, seeds = 20'
|
||||
)
|
||||
|
||||
plt.plot([50, 10000], [1.71, 1.71], color='red', label='Theory')
|
||||
plt.fill_between(without_prefix.N, 1.71 - 0.01, 1.71 + 0.01, alpha=0.2, label='Theory error band')
|
||||
|
||||
plt.xlabel("$N_C$")
|
||||
plt.ylabel("$fd$ (instantaneous)")
|
||||
plt.legend()
|
||||
|
||||
plt.savefig('../figures/nc-fd-convergence.svg')
|
||||
plt.savefig('../figures/nc-fd-convergence.png')
|
||||
plt.show()
|
||||
File diff suppressed because one or more lines are too long
10
tools/3d-harness.bash
Executable file
10
tools/3d-harness.bash
Executable file
@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# NOTE: Requires GNU parallel
|
||||
|
||||
KEY="$1"
|
||||
MODEL="models/$KEY"
|
||||
mkdir -p data/$KEY
|
||||
|
||||
parallel "$MODEL" '{1}' '{2}' '{3}' "data/$KEY/{1}.csv" ::: $(seq 53 100) ::: 5000 ::: 1
|
||||
|
||||
@ -3,6 +3,8 @@
|
||||
# NOTE: Requires GNU parallel
|
||||
|
||||
MODEL="models/minimal-viable-alteration"
|
||||
mkdir -p data/minimal-viable-alteration
|
||||
ROOT="data/alpha"
|
||||
|
||||
parallel "$MODEL" '{1}' '{2}' 'data/minimal-viable-alteration/{1}-{2}.csv' ::: {1..20} ::: $(seq 1000 1000 5000)
|
||||
mkdir -p $ROOT
|
||||
|
||||
parallel "$MODEL" '{1}' '{2}' "$ROOT/{1}.csv" ::: {1..20} ::: 10000
|
||||
|
||||
BIN
tools/rust-tools
Executable file
BIN
tools/rust-tools
Executable file
Binary file not shown.
Loading…
Reference in New Issue
Block a user