#!/usr/bin/env python3 """Sensitivity S1 and S2 of RULES_set_aside.txt: the note's tests with the March 2023 record set aside, and with the April 2000 photograph set aside as well. Fact-Checked Science ("Our analysis"), for /florida-aurora-cycle-25/. Standard library only; no data files are read: the counts are those of storm_lists.py and reproduce_note.py. Run: python3 -I set_aside.py """ import datetime as dt import os import sys sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) from fclib import binom_sf, fisher_one_sided, poisson_sf, sig # noqa: E402 sys.stdout.reconfigure(encoding="utf-8", newline="\n") SCALE = 6.9 / 10.95 # the note's exposure share CYCLES = 15 E25 = (dt.datetime(2026, 10, 30, 14) - dt.datetime(2019, 12, 1)).total_seconds() / 86400 / 365.25 # to the note's freeze E_ALL = 2019.958 - 1855.958 # SILSO minima, cycle 10 to cycle 25 E_MOD = 2019.958 - 1986.708 # cycle 22 to cycle 25 def rate_line(label, n_all, n_mod, ks=(5, 4, 3, 2)): lam, lam_m = n_all / CYCLES, n_mod / 3 print(" %s: %d events in 15 cycles (lambda %.3f); cycles 22-24: %d (lambda %.3f)" % (label, n_all, lam, n_mod, lam_m)) for k in ks: c1 = binom_sf(k, k + n_all, E25 / (E25 + E_ALL)) c1m = binom_sf(k, k + n_mod, E25 / (E25 + E_MOD)) print(" k = %d: full cycle p = %9s; scaled by 0.630: %9s; modern only: %9s; C1 all cycles: %9s; C1 modern: %9s" % (k, sig(poisson_sf(k, lam)), sig(poisson_sf(k, lam * SCALE)), sig(poisson_sf(k, lam_m)), sig(c1), sig(c1m))) def fisher_block(label, n0, n1, h1s, h0s): print(" " + label) for name, h0 in h0s: cells = "; ".join("%d/%d vs %d/%d: p = %s" % (h0, n0, h1, n1, sig(fisher_one_sided(h1, n1, h0, n0))) for h1 in h1s) print(" %-58s %s" % (name, cells)) def main(): print("SENSITIVITY (rules: RULES_set_aside.txt). k = 5 all five records; k = 4 March 2023 set aside;") print("k = 3 seen by eye, with October 2024; k = 2 naked eye stated (May 2024, November 2025)") print() print("S1. Rate test, exact one-sided Poisson (C1 = the two-rate binomial test)") print(" Baseline: the note's inventory") rate_line("Path A", 6, 3) rate_line("Path B", 9, 3) print(" Baseline: with documented Florida additions (1859's second storm, February 1958 for Path A, April 2000, November 2001)") rate_line("Path A", 10, 5) rate_line("Path B", 12, 5) print(" Baseline: with inferred additions too (July 2000, November 2004)") rate_line("Path A", 12, 7) rate_line("Path B", 14, 7) print(" Baseline: Path B with the Gulf equivalents found in passing (1959, 1969, March 2001)") rate_line("Path B", 15, 6) print() print("S2. As S1's documented baseline, with the April 2000 photograph set aside as well") rate_line("Path A", 9, 4) rate_line("Path B", 11, 4) print() print("S1. Storm test, one-sided Fisher (1986-November 2019 against cycle 25); cycle 25 with 5 and with 4 records") base = [("T0 the note's table", 3), ("T1 plus the April 2000 photograph", 4), ("T2 plus November 2001's sentence (S2: without April 2000 = T1's count)", 5), ("T3 plus inference", 7)] fisher_block("Kp >= 8- (76 storms against 13)", 76, 13, (5, 4), base) fisher_block("Kp >= 8o (52 storms against 9)", 52, 9, (5, 4), base) fisher_block("Kp >= 9- (19 against 4; March 2023 is not in this stratum)", 19, 4, (4,), base) fisher_block("Dst <= -200 nT (30 against 6; March 2023 is not in this stratum)", 30, 6, (4,), base) print() print("The title's arithmetic") for k in (5, 4): for lam, name in ((0.60, "Path B"), (0.40, "Path A")): cyc = k / lam print(" %d events at %.2f a cycle (%s) = %.2f cycles = %.1f years at 10.95, %.1f at 10.93" % (k, lam, name, cyc, cyc * 10.95, cyc * (164.0 / 15))) d5 = (dt.date(2026, 1, 20) - dt.date(2023, 3, 23)).days d4 = (dt.date(2026, 1, 20) - dt.date(2024, 5, 10)).days print(" span of the five records, 23 March 2023 to 20 January 2026: %d days = %.2f years" % (d5, d5 / 365.25)) print(" span of the four, 10 May 2024 to 20 January 2026: %d days = %.2f years" % (d4, d4 / 365.25)) print(" 'nearly matched the previous 160 years combined': 4 against 6 (Path A) or 9 (Path B); with the documented") print(" additions, 4 or 5 against 10 (Path A) or 12 (Path B)") if __name__ == "__main__": main()