Conditional spacetime-cluster sampler for rare neural trajectories / run_experiment.py

Failed on benchmark

Raw ⬇ ZIP
 1import json
 2from conditional_cluster_sampler import run_case, transition, exact_terminal_probability
 3
 4# Fixed seeds and bounded proposal budget make this reproducible and safe to run.
 5results = [run_case(a) for a in (0.05, 0.005, 0.0005)]
 6checks = []
 7for r in results:
 8    checks.append({
 9        "a": r["a"],
10        "prediction_acceptance_Z": r["acceptance_pred"],
11        "observed_acceptance": r["proposal_acceptance"],
12        "relative_error": abs(r["proposal_acceptance"]-r["acceptance_pred"])/r["acceptance_pred"],
13        "prediction_rejection_cost_1_over_Z": r["rejection_cost_pred"],
14        "observed_cluster_valid_fraction": r["cluster_valid"],
15        "cluster_mean": r["cluster_mean"],
16        "exact_conditioned_mean": r["exact_mean"],
17        "conditioned_TV_error": r["tv"],
18        "cluster_ESS": r["cluster_ess"],
19        "local_Gibbs_ESS": r["local_ess"],
20    })
21with open("results.json", "w") as f:
22    json.dump({"settings": {"T": 10, "n_cluster": 200, "n_proposals": 20000, "seed": 123},
23               "checks": checks}, f, indent=2)
24for row in checks:
25    print(json.dumps(row))