Download code/work/jk_pooled.py from bryan7264/lorapop: direct link, hf CLI and curl.
- Browser
- Download file 1.19 kB
-
https://huggingface.co/datasets/bryan7264/lorapop/resolve/main/code/work/jk_pooled.py
- Command line
-
hf download hf://datasets/bryan7264/lorapop/code/work/jk_pooled.py
-
curl -L -o jk_pooled.py https://huggingface.co/datasets/bryan7264/lorapop/resolve/main/code/work/jk_pooled.py
1.19 kB
| # MIT License, Bryan Cheng, 2026. | |
| """Pooled family jackknife over traits (D-044): the groups are the same for every trait (same seed and families), so the | |
| median over traits of lambda (and of naive - MM-fd) can be jackknifed with the per-group values stored in lambda_jk.""" | |
| import json | |
| import numpy as np | |
| J = json.load(open("results/scans/qwen05_rt/lambda_jk.json")) | |
| T = list(J["traits"]) | |
| G = J["groups"] | |
| jk = np.array([J["traits"][t]["jk"] for t in T]) # [traits, groups, 2] | |
| pt = np.array([[J["traits"][t]["naive"]["lambda"], J["traits"][t]["mm_fd"]["lambda"]] for t in T]) | |
| out = {} | |
| for name, f in (("median_naive", lambda a: np.median(a[..., 0], 0)), ("median_mm_fd", lambda a: np.median(a[..., 1], 0)), | |
| ("median_diff", lambda a: np.median(a[..., 0] - a[..., 1], 0))): | |
| th = float(f(pt[:, None, :])[0]) if False else float(f(pt)) | |
| th_g = np.array([f(jk[:, g, :]) for g in range(G)]) | |
| se = float(np.sqrt((G - 1) / G * ((th_g - th_g.mean()) ** 2).sum())) | |
| out[name] = {"value": th, "se_jk": se, "ci95": [th - 1.96 * se, th + 1.96 * se]} | |
| print(json.dumps(out, indent=1)) | |
| json.dump(out, open("results/scans/qwen05_rt/lambda_jk_pooled.json", "w"), indent=1) | |