diff --git a/.crumb b/.crumb index 28c4193f5..46e28cb9a 100644 --- a/.crumb +++ b/.crumb @@ -51,8 +51,8 @@ "purpose": "Directory calibration. Purpose not yet described by a human." }, { - "digest": "7d4fb8a4ca16a4e4efb7734e098157e697f84678b641df869ed0bb3f0caa37a1", - "last_commit": "c847a16", + "digest": "01a9aa128e136ecccdaca33b6babef24d4011a95c2ca1a5dd839d84e2841ce3d", + "last_commit": "8fd3afe", "name": "docs", "purpose": "Directory docs. Purpose not yet described by a human." }, @@ -63,8 +63,8 @@ "purpose": "Directory doctrine. Purpose not yet described by a human." }, { - "digest": "2b9abab41d977b59a4c2028721f9eed109694da67caee74a589b795891995ac2", - "last_commit": "f1da160", + "digest": "7a280ae41e1051f14529ab2c8b2749f4712ea37df87254fd90bfbc3e1bba2048", + "last_commit": "4c8a6a6", "name": "mk", "purpose": "Directory mk. Purpose not yet described by a human." }, @@ -99,21 +99,21 @@ "purpose": "Directory tests. Purpose not yet described by a human." }, { - "digest": "1987becea7850243107a1e552c1a279bc4fca82a7a94c7b2b4c540cdf06fee35", - "last_commit": "c847a16", + "digest": "39a4a935c81a9ba2a047be53e745857892c48a9c9e17f5f166e037d36f7a28b6", + "last_commit": "8fd3afe", "name": "tools", "purpose": "Directory tools. Purpose not yet described by a human." } ], - "children_root": "sha256:f9d2277fcc55ff0a736f1f4551f97efd92d9bbbbe986eda759a58b5e6ecef56d", - "compiled_at": "2026-10-05T16:36:21Z", + "children_root": "sha256:bc9f475ac36f9249b2ad2b117425648b2af81a459f7ea945124342166cb0a62f", + "compiled_at": "2026-10-05T16:48:41Z", "compiler": "crumb-compile/1", - "digest": "sha256:1ef14545f2defdf28842f90f1a5034f5c158bb2214515ae2af960c0b71eb1284", - "evidence_files": 2770, - "evidence_root": "sha256:02119bd8a3cb15fc8a83ca7813cb036b850b6bcfdbd6203fac6d247dc9017550", - "files": 4569, - "generated_at_commit": "c847a167bdaeb6e2dc997a46c37057639bb39412", - "source_tree": "sha256:80880a6285a4e4788daa8a015cc51798ee1089e107366d088f3fa669fa8b2d0a" + "digest": "sha256:5772ef67488f0a92f58a6c01a47ac228d4cbaf0513df141d039ac7bd64f8db70", + "evidence_files": 2773, + "evidence_root": "sha256:9b7e635d548d619fa71619fe08c4e37fc207feeb04bf6f9c6b0faa7ea4c3a533", + "files": 4573, + "generated_at_commit": "678ed89f7b0213130c92d20d481bf429414772e2", + "source_tree": "sha256:aa10fa3437a5fb46adc9b934de2c4c077f152094409b92378c3261b10c803ed0" }, "owner_lane": "", "provenance": { diff --git a/docs/.crumb b/docs/.crumb index a5dd71a54..b1461bf83 100644 --- a/docs/.crumb +++ b/docs/.crumb @@ -75,8 +75,8 @@ "purpose": "DUAL (ARCH-0031) documents in omega: applicability experiment method and findings (APPLICABILITY" }, { - "digest": "e1c9f57d05abe38c7e26d0ff4e03e9a845da7dd09cd0c6f0763d20348b637618", - "last_commit": "a386d65", + "digest": "56a5a999ce726e90d89c1c88b9e20c81857c8e6ee82af8d651ac80ea70e2c46d", + "last_commit": "25311c0", "name": "estimation", "purpose": "Directory docs/estimation. Purpose not yet described by a human." }, @@ -117,15 +117,15 @@ "purpose": "Directory docs/turing. Purpose not yet described by a human." } ], - "children_root": "sha256:f2a14defafba3c9064172c63652f52182db9471d4002cc77690d164a1736a255", - "compiled_at": "2026-10-05T14:59:30Z", + "children_root": "sha256:ce53c9c7f75a7d122d6a926bb304b2df1bd0730693b54887b842ad3559bafe83", + "compiled_at": "2026-10-05T15:40:51Z", "compiler": "crumb-compile/1", - "digest": "sha256:7d4fb8a4ca16a4e4efb7734e098157e697f84678b641df869ed0bb3f0caa37a1", - "evidence_files": 31, - "evidence_root": "sha256:3f4d8ab7c723c9fddacc5a872541933a4b87d1bb39868b8ec376320db6c929af", - "files": 109, - "generated_at_commit": "a386d65ed193a02dccac444de3fd3224c96162b4", - "source_tree": "sha256:8f71f1258afc0c4fb3e80a574409d90fed0f89a5990d31ee50e0ba4e83004f94" + "digest": "sha256:01a9aa128e136ecccdaca33b6babef24d4011a95c2ca1a5dd839d84e2841ce3d", + "evidence_files": 34, + "evidence_root": "sha256:589d8b3706e6d7a202ab20b278dac5fc5bafc973f1c2a867b2668aa7210b65cc", + "files": 112, + "generated_at_commit": "25311c0c2aee4eb4991052115d9ad91f5b4d2a1e", + "source_tree": "sha256:cb189c97510cfdc47126abee0105eb8dba61520c3f654644838eba1f08a930ad" }, "owner_lane": "", "provenance": { diff --git a/docs/estimation/.crumb b/docs/estimation/.crumb index 063967103..795b246ae 100644 --- a/docs/estimation/.crumb +++ b/docs/estimation/.crumb @@ -24,14 +24,14 @@ } ], "children_root": "sha256:35cd3af03e079556db7f3ebcfd7590fa68659e84dd603795ae6b5b048dc2af0d", - "compiled_at": "2026-10-05T14:59:30Z", + "compiled_at": "2026-10-05T15:40:51Z", "compiler": "crumb-compile/1", - "digest": "sha256:e1c9f57d05abe38c7e26d0ff4e03e9a845da7dd09cd0c6f0763d20348b637618", - "evidence_files": 31, - "evidence_root": "sha256:3f4d8ab7c723c9fddacc5a872541933a4b87d1bb39868b8ec376320db6c929af", - "files": 44, - "generated_at_commit": "a386d65ed193a02dccac444de3fd3224c96162b4", - "source_tree": "sha256:9c4fd50874b3be4f7d7afe4c52446c3ef9783204640a72b253b684e1cdc7c30c" + "digest": "sha256:56a5a999ce726e90d89c1c88b9e20c81857c8e6ee82af8d651ac80ea70e2c46d", + "evidence_files": 34, + "evidence_root": "sha256:589d8b3706e6d7a202ab20b278dac5fc5bafc973f1c2a867b2668aa7210b65cc", + "files": 47, + "generated_at_commit": "25311c0c2aee4eb4991052115d9ad91f5b4d2a1e", + "source_tree": "sha256:67ae8d20aca3ae36b8cf0d75c6939058cc9ff8762c977f70d6963c545e3215d8" }, "owner_lane": "", "provenance": { diff --git a/docs/estimation/protocols/est-v6-appendix-prefreeze.md b/docs/estimation/protocols/est-v6-appendix-prefreeze.md index 8c506370e..f8e0aa02c 100644 --- a/docs/estimation/protocols/est-v6-appendix-prefreeze.md +++ b/docs/estimation/protocols/est-v6-appendix-prefreeze.md @@ -169,7 +169,7 @@ Rule SR-1 (implemented in `est6dev plan6`, default rule): 5. The effective seed (64 bit) is what is passed to `est_load` (it reads it with `strtoull`, `est_load.c:73`), and the whole segment list is written into the frozen file. -Required properties (checked by `make test-est6dev`, 35 checks in total, of which the schedule ones are in the block +Required properties (checked by `make test-est6dev`, 43 checks in total, of which the schedule ones are in the block "2b"): the segments of each label sum to exactly 2700 s; every segment is 20 to 120 s except that the last may be clipped; each level totals 400 to 900 s; H1 and H2 (and F) have different effective seeds and different segment lists; the same declared seed under two labels gives two schedules; the same input gives byte-identical output; a label's @@ -195,6 +195,8 @@ matters to calibration, and it does not claim any schedule is representative. ## 4. Item 2: G1S fit with block cross-validation (REDUCED, not the full item) +(Superseded in part: the full item was done afterwards, section 4b. This section is kept as the record of the reduced check.) + Size assessment of the full item. The protocol's G1S fit is a new model plus the whole fit machinery with block CV: a two-piece Student-t discretiser that must equal `est_v4.c` bit for bit at kappa 1.0 (a new `est_v6.c`, about 150 lines with its own t CDF, or an edited copy of `est_v4.c`), segment-fold bookkeeping, @@ -254,6 +256,121 @@ Reading (PROVEN as numbers, interpretation LIKELY): met cleanly: kappa 0.9 was chosen in 2 of 5 folds and bin 0 rose. A decision on G1S versus a regime-aware remedy (v6 section 5 excluded regime-conditioned scale) needs the full item and belongs to the freeze lane. +## 4b. Item 2 completed: full G1S fit with block cross-validation (DEVELOPMENT RESULT) + +Everything in this section is a DEVELOPMENT RESULT on v5 D1 (and, separately, v3 D1). It is not a held-out result, it +changes no v5 file and no v6 protocol text, and v6 stays NOT FROZEN. Raw outputs are committed unedited: +`docs/estimation/receipts/est-v6-dev/g1sfull-v5d1.txt` and `g1sfull-v3d1.txt`. Command (about 6 minutes each): + +``` +est6dev g1sfull --raw /machine-state.ndjson --marks /machine-state-marks.txt +``` + +What it does, as `est-v6.md` section 5 specifies. Stage 1: the whole G1 grid (dyn 6 x q 9 x lam 7 x nu 7 x c 21) times kappa +in {0.6, 0.7, 0.8, 0.9, 1.0}: 55566 (dyn, q, lam, nu, c) points, each scored at five kappa values. The lam grid is extended +downwards by 0.05 as v6 section 5 item 5 says (v5 had 0.1 to 0.9). Folds: the rank of each block (whole load segment, or idle +stretch between marked segments) modulo 5; the grid is searched on 4 folds and the held-out fold is scored. Selection key: the +pooled out-of-fold one-step mean log score. Stage 2, per fold on the training folds with that fold's stage 1 frozen: +(phi, nu_h, c_h, kappa_h) over 5 x 10 x 31 x 5, scored on the ten-step log score. A control with kappa fixed at 1.0 (G1 exactly) +is fitted under the same folds, grid and rules. The final whole-pool refit is also printed. + +Implementation notes and checks (each from `make test-est6dev`). +- The two-piece Student-t has side masses 1/(1+kappa) and kappa/(1+kappa), scale c on the upper side and c kappa on the lower + side, so the density is continuous at the location. `est6dev twopiece-selfcheck` checks, over 5 kappa x 3 nu x 3 scale x + 3 location, that the bin probabilities sum to 1 (max error 1.1e-14), that the floored CDF has no jump between bins (0) and is + monotone, and that the two-piece formula at kappa 1.0 agrees with `est4_fast_logp` to 1.2e-11. +- At kappa = 1.0 the code path calls the unchanged `est4_fast_logp`, so the control is G1 exactly (bit for bit by construction). + The formula check above is therefore only to rounding (1.2e-11), not bit for bit. A bit-for-bit `est_v6.c` library is still OPEN. +- Whole-pool refit on v5 D1 returns dyn 1, q 10000, lam 0.1, nu 1.25, c 0.70, kappa 1.0 with mean log score -1.962811: the v5 G1 + selection and score of `receipts/est-v5/params.txt`, now found by a grid that also contains the new lam value and all kappa. + The extended lam value 0.05 and kappa below 1 do not win in sample on v5 D1. +- Same 2652 steps as `est6dev g1pit` (grid line `steps 2652`); a test asserts it. + +Out-of-fold result, pooled over the 5 folds (DEVELOPMENT RESULT, v5 D1, n 2652): + +| quantity | G1S (kappa free) | control G1 (kappa 1.0) | +|---|---|---| +| out-of-fold one-step mean log score | -1.969622 | -1.968162 | +| kappa chosen in folds 0 to 4 | 1.0, 1.0, 0.9, 0.9, 1.0 | 1.0 in all | +| pit_bin0 / pit_bin9 | 0.0853 / 0.1199 | 0.0766 / 0.1233 | +| lower / upper miss 2.5 % | 0.0138 / 0.0340 | 0.0126 / 0.0356 | +| coverage 50 / 80 / 95 | 0.4943 / 0.7947 / 0.9522 | 0.5003 / 0.8001 / 0.9518 | +| mean z (mid-PIT) / lag-1 z | 0.022 / -0.021 | 0.047 / -0.024 | +| ten-step coverage 95 (stage 2 per fold) | 0.9410 | 0.9402 | + +Same procedure on v3 D1 (separate development data, n 2651, not pooled with v5 D1): + +| quantity | G1S | control G1 | +|---|---|---| +| out-of-fold one-step mean log score | -1.593744 | -1.596005 | +| kappa chosen in folds | 0.9 in all 5 | 1.0 in all | +| pit_bin0 / pit_bin9 | 0.0929 / 0.1041 | 0.0830 / 0.1190 | +| lower / upper miss | 0.0179 / 0.0304 | 0.0166 / 0.0344 | +| ten-step coverage 95 | 0.9551 | 0.9684 | + +Readings, each from the numbers above (no tuning to them was done: grids and rules were fixed by the proposal before the run). +- PROVEN as numbers: G1S is worse than G1 by 0.0015 nats out of fold on v5 D1 and better by 0.0023 nats on v3 D1. Both gaps are + far below the 0.01 nat tie rule of v6 section 5 item 3, so that rule keeps G1 on both sets. The log score does not support G1S. +- PROVEN as numbers: G1S moves bin 0 up (0.0766 to 0.0853 on v5 D1, 0.0830 to 0.0929 on v3 D1, about +0.009 and +0.010) and bin 9 down + (0.1233 to 0.1199, and 0.1190 to 0.1041), as hypothesised. + This is a calibration-shape effect that costs no log score, not evidence of better forecasting. G2 and G3 were not run here. +- Inner-band screen of v6 section 5 item 2 (each outcome is in the raw files; the `gate` lines). Read literally, the screen + cannot be passed by any model, which is a **defect in the proposal to fix before freeze**: (i) P3 coverage 95 has band + [0.93, 0.97] shrunk by 0.02 on both sides, a zero-width band at exactly 0.95; (ii) P4 and P5, if the 0.01 shrink applies to the + miss rates, become [0.020, 0.030], which rejects a lower miss of 0.0126 to 0.0179 and an upper miss of 0.030 to 0.036 on every + fit here, G1 and G1S alike. If the shrink is read as applying only to P1, P2, P6 and P7: on v5 D1 G1S passes P6 bin 0 (0.0853) + and bin 9 (0.1199, margin 0.0001) and G1 fails both (0.0766, 0.1233); on v3 D1 both pass P6 and G1 fails the inner P7 (0.9684 + against 0.96). So under that reading G1S would pass the screen where G1 does not, on v5 D1, and the 0.01 nat rule applies only + among screen passers (v6 section 5 item 3), so G1S would then be selected on v5 D1. That outcome rests on a bin 9 margin of 0.0001. +- Whether to adopt G1S is therefore OPEN and depends on the freeze lane's reading of the inner-band rule. + +### Load-dependent calibration bias (DEVELOPMENT RESULT; v5 D1 and v3 D1, out of fold) + +Out-of-fold PIT by declared load level. Block bootstrap within each level (whole blocks, 2000 draws, seed 0xE6B007 + level index), +standard errors in brackets (few blocks per level, so the standard errors are themselves rough). `m` is the mean of (u - 0.5): zero +for an unbiased forecaster, negative when outcomes land below the forecast median (forecast too warm), positive when above. + +v5 D1: + +| level | steps | blocks | G1S bin0 | G1S bin9 | G1S m | G1 bin0 | G1 bin9 | G1 m | +|---|---|---|---|---|---|---|---|---| +| idle | 818 | 8 | 0.129 (0.007) | 0.075 | -0.070 (0.008) | 0.115 (0.010) | 0.077 | -0.061 (0.010) | +| L6 | 739 | 10 | 0.129 (0.009) | 0.109 | -0.027 (0.010) | 0.114 (0.007) | 0.118 | -0.016 (0.009) | +| L12 | 970 | 14 | 0.026 (0.007) | 0.158 | +0.063 (0.010) | 0.025 (0.007) | 0.159 | +0.065 (0.011) | +| L18 | 125 | 3 | 0.001 (0.001) | 0.183 | +0.121 (0.016) | 0.000 (0.000) | 0.184 | +0.127 (0.018) | + +v3 D1: + +| level | steps | blocks | G1S bin0 | G1S bin9 | G1S m | G1 bin0 | G1 bin9 | G1 m | +|---|---|---|---|---|---|---|---|---| +| idle | 235 | 4 | 0.160 (0.017) | 0.084 | -0.088 (0.015) | 0.149 (0.020) | 0.089 | -0.070 (0.015) | +| L6 | 672 | 12 | 0.175 (0.015) | 0.116 | -0.046 (0.015) | 0.158 (0.013) | 0.134 | -0.030 (0.015) | +| L12 | 1079 | 16 | 0.056 (0.008) | 0.101 | +0.029 (0.008) | 0.049 (0.007) | 0.117 | +0.041 (0.009) | +| L18 | 665 | 7 | 0.046 (0.005) | 0.105 | +0.033 (0.009) | 0.040 (0.005) | 0.118 | +0.046 (0.010) | + +Findings. +- PROVEN as numbers, on both development sets: the bias is monotone in load. The forecast is too warm when idle (m -0.06 to -0.09) + and too cool at L12 and L18 (m +0.03 to +0.13). Idle against L12, in units of the larger of the two bootstrap standard errors: + v5 D1 G1S (0.063 + 0.070) / 0.010 is about 13; v3 D1 G1S (0.029 + 0.088) / 0.015 is about 8. Even allowing for rough standard + errors, this is not noise. Bin 0 is over-filled at idle and L6 (0.11 to 0.18) and under-filled at L12 and L18 (0.00 to 0.06). +- PROVEN as numbers: it is not stable in size across runs. L18 bin 0 is 0.001 on v5 D1 (125 steps, 3 blocks) and 0.046 on v3 D1 + (665 steps, 7 blocks). So per-level shares measured on one run cannot be assumed on the next. +- PROVEN as numbers: G1S does **not** remove it. It has the same sign at every level and the same order of size as G1. On v5 D1 + idle m is -0.070 against -0.061 and L12 is +0.063 against +0.065; on v3 D1 it trims the high levels (L12 +0.029 against +0.041, + L18 +0.033 against +0.046) and enlarges the low ones (idle -0.088 against -0.070, L6 -0.046 against -0.030). Bin 0 stays + above 0.11 at idle and L6 and below 0.06 at L12 and L18 in both. The pooled m of G1S on v5 D1 (-0.0006, G1 +0.0064) is closer to + zero only because the opposite per-level biases cancel in the pool. +- No load covariate is permitted by the proposal (v6 section 5 "Not adopted": regime-conditioned scale and anything that feeds the + declared schedule to the estimator), so none was fitted here. The bias is therefore **not resolved** by anything v6 proposes. It + is LIKELY a model-structure limit (the filter lags load steps; not tested here) and would need a v7-class remedy or a changed claim. +- Consequence for the pooled held-out gates (a projection, UNVERIFIED, assuming each level's shares transfer from D1). Weight the + per-level bin shares by the level seconds that rule SR-1 gives H1 + H2 (idle 1343, L6 1408, L12 1107, L18 1542 of 5400; + weights 0.249, 0.261, 0.205, 0.286). With the v5 D1 per-level numbers the pooled expectation is bin 0 0.0713 (G1S) and 0.0637 (G1), + bin 9 0.1318 (G1S) and 0.1350 (G1): bin 9 above 0.13 for both, bin 0 below 0.07 for G1. With the v3 D1 per-level numbers it is bin 0 + 0.110 (G1S) and 0.100 (G1), bin 9 0.102 and 0.115: no gate broken. The two disagree, which is the instability above. The pooled + held-out result depends on the realised level mix and on per-level shares nobody can predict from D1, so the balance rule alone + does not make the pooled test insensitive to the regime bias. + ## 5. Item 3: operating characteristics of the v6 verdict Tool: `est6opchar` (reads no data file; `make est6-opchar-table`, 4000 replicates, 1000 bootstrap draws each, @@ -316,11 +433,81 @@ Limits of the simulation: the data-generating model is a Gaussian copula with a forecaster; real clustering is partly a regime bias (section 2) that is not noise and not random across replicates; P7 is crude; the baseline comparison and the real est_load level structure are not simulated. +## 5b. Item 3 extended: operating characteristics, SIMULATION only (not forecasting performance) + +Everything here is SIMULATION. No data file is read (`est6opchar` has no input path), so no held-out file can be touched. The numbers +describe how the proposed three-way verdict of v6 section 6 behaves on synthetic PIT sequences under the stated assumptions, not how +any forecaster performs. Raw rows: `docs/estimation/receipts/est-v6-dev/opchar-table2.txt`; command `make est6-opchar-table2` +(20000 replicates per row, 1000 bootstrap draws, Monte Carlo standard error at most 0.0035 on every rate). + +Definitions used below. False accept: the verdict is PASS although the simulated forecaster truly breaks a gated limit. False reject: +the verdict is not PASS although the forecaster is truly calibrated (reported both as not PASS and as HELD_OUT_FAIL). NOT_ESTABLISHED +is neither accept nor reject. + +Assumptions (explicit, all as in section 5 unless new): two pooled 2700 s runs (n about 5300, P10 met); segments 20 to 120 s with a +uniformly random level; Gaussian copula with per-segment share w (0.08 and 0.12, the measured design-effect range 3.3 to 4.5) and +within-segment AR(1) 0.02; ten-step sequence with within-segment AR(1) 0.9; baseline comparison assumed met; lag-1 z, P9 quarters and +regimes use the point value (this can only increase HELD_OUT_FAIL). New in 5b: case (d), a forecaster whose PIT depends on the +declared load level, with the per-level shares measured for G1 on v5 D1 (section 2: bin 0 0.116, 0.111, 0.025, 0.000; bin 9 0.077, +0.114, 0.159, 0.184; lower miss 0.030, 0.010, 0.000, 0.000; upper miss 0.036, 0.017, 0.041, 0.085 for idle, L6, L12, L18) with bins 1 +to 8 sharing the rest equally (ASSUMPTION: per-level middle bins were not tabulated) and random segment levels, so the level mix is +about equal (the "bin0 0.0760" in the printed header of a case d row is a default that case d does not use). + +Results (SIMULATION, two runs unless stated; PASS / NOT_ESTABLISHED / HELD_OUT_FAIL): + +| scenario | w | runs | PASS | NOT_EST | HELD_OUT_FAIL | +|---|---|---|---|---|---| +| (a) calibrated, replication seed 0xE6A777 | 0.08 | 2 | 0.9931 | 0.0069 | 0.0000 | +| (a) calibrated | 0.08 | 3 | 0.9988 | 0.0013 | 0.0000 | +| (b) nominal 95 % covers 92 %, replication | 0.08 | 2 | 0.0017 | 0.5644 | 0.4339 | +| (b) | 0.08 | 3 | 0.0003 | 0.3752 | 0.6244 | +| (d) regime-dependent PIT (D1 per-level shares) | 0.08 | 2 | 0.0656 | 0.8536 | 0.0809 | +| (d) | 0.08 | 3 | 0.0475 | 0.8518 | 0.1007 | +| (d) | 0.12 | 2 | 0.0726 | 0.8061 | 0.1214 | +| (d) | 0.12 | 3 | 0.0592 | 0.8327 | 0.1081 | + +The replication under another seed agrees with table 5 (a: 0.9931 against 0.9928; b: PASS 0.0017 against 0.0025), so the +table-5 numbers are not seed luck. + +False accept for a forecaster whose true bin 0 is below the 0.07 limit (case c cells, w 0.08; other cells scaled pro rata): + +| true bin 0 | runs 2: PASS / NOT_EST / HELD_OUT_FAIL | runs 3: PASS / NOT_EST / HELD_OUT_FAIL | +|---|---|---| +| 0.070 (at the limit) | 0.403 / 0.587 / 0.010 | 0.442 / 0.552 / 0.007 | +| 0.068 | 0.294 / 0.685 / 0.021 | 0.300 / 0.682 / 0.019 | +| 0.065 | 0.152 / 0.793 / 0.055 | 0.125 / 0.807 / 0.068 | +| 0.060 | 0.027 / 0.761 / 0.212 | 0.012 / 0.677 / 0.311 | +| 0.055 | 0.0015 / 0.470 / 0.528 | 0.0004 / 0.282 / 0.718 | + +Readings (each from the tables; interpretation labelled). +- Requirements of v6 section 6 are met by the SIMULATION at w 0.08 and 0.12 with two runs: false reject under (a) is 0.7 % (not PASS) and + 0 % (HELD_OUT_FAIL) at w 0.08 (table 5: 2.7 % and 0.4 % at w 0.12); pass under (b) is 0.2 %. This is conditional on the assumptions + above; w 0.20 (table 5) still fails, and real clustering structure is not a Gaussian copula. +- False accept is controlled only for shortfalls that are not small: a forecaster 0.005 under the limit (bin 0 0.065) is accepted + 15 % of the time with two runs and 13 % with three, and one 0.002 under (0.068) 29 to 30 %. This is inherent to a point-value PASS + at a hard edge: PASS needs only the point value inside the band, and an edge-sitting forecaster lands on either side by chance. + The simulation says nothing that would make the PASS rule safer than a coin flip at the edge, and three runs do not help there. +- Definite rejection is slow: HELD_OUT_FAIL needs the 99.5 % interval entirely below the edge. A bin 0 of 0.060 is called a definite + fail 21 % (two runs) or 31 % (three) of the time, and mostly reported NOT_ESTABLISHED. A 92 % forecaster is a definite fail 43 % + (two runs) or 62 % (three) of the time. +- Regime-biased forecaster (d): it passes only 5 to 7 % of the time, is called a definite fail only 8 to 12 %, and is reported + NOT_ESTABLISHED about 81 to 85 % of the time. So a forecaster with the D1 regime bias would very probably be neither accepted nor + refuted. LIKELY reason (not decomposed here): several gates (bin 0, bin 9, the P9 regime coverages) each sit near or past an edge at once. +- Three runs lower false accept at moderately bad cells (0.060: 2.7 % to 1.2 %) and raise definite-fail power (0.21 to 0.31), at the + cost of another quiet window of about 45 minutes. They do not help at the edge (0.070: 40 % to 44 %). +- Limits (INCONCLUSIVE where stated): the data-generating model is a Gaussian copula with a segment effect; the level structure + matters (section 4b shows per-level shares are unstable across runs) and is only partly simulated in (d) with one set of D1 shares; + P7 is crude; the baseline comparison is not simulated; whether a v6 PASS licenses the section 7 claim at stated operating + characteristics is therefore **INCONCLUSIVE** from this simulation alone, since the required table has been produced but the + simulation's assumptions have not been shown to hold for the real forecaster. + ## 6. What this appendix does not do -Item 5 is not done (hashes, `est_v6.c`, freeze commit). The full G1S fit (item 2) is not done; the design note is in -section 4. No v6 text was changed, so the findings above (seed collision, balance rule applied by chaining, regime -dependence, the G1S inner-band outcome, the weak definite-fail power of the verdict) are for the freeze lane to act on. +Item 5 is not done (hashes, `est_v6.c`, freeze commit). The full G1S fit (item 2) is now done as a DEVELOPMENT RESULT (section 4b) +and its load-bias finding is unresolved; the operating-characteristics extension is section 5b (SIMULATION); the schedule defect has +rule SR-1 (section 3b). `est-v6.md` itself was not changed (it is a PROPOSAL; the freeze text must absorb 3b and the inner-band +fix of 4b), so the findings of this appendix (regime dependence, the G1S outcome, the weak definite-fail power of the verdict, the +inner-band definition) are for the freeze lane to act on. The checklist of what is still open is section 8. Nothing here uses or concerns held-out data. ## 7. Reproduction, hashes @@ -329,9 +516,45 @@ Nothing here uses or concerns held-out data. make test-est6dev # tools tests, D1 and synthetic data only make est6dev est6opchar make est6-opchar-table # section 5 table +make est6-opchar-table2 # section 5b SIMULATION table (20000 replicates per row, a few minutes) +est6dev plan6 2700 F=0xE6C6D1 H1=0xD6E6C7 H2=0xD6E6C8 # section 3b +est6dev g1sfull --raw /machine-state.ndjson --marks /machine-state-marks.txt # section 4b (about 6 minutes) ``` - `docs/estimation/protocols/est-v6.md` sha256 `4fee44c729130cb37e5588b105077f4d8c17ea8c160dbfb310fdec720ff6316f` (commit e9c2829). -- `tools/estimation/est6dev.c` sha256 `c020ee872be90f7cdd62a56a8bd0c8f09e20f3ae4cdd659ccbb2b18b90e81c4d`; +- Sections 1 to 5 hashes (tools as merged in #293): `tools/estimation/est6dev.c` sha256 `c020ee872be90f7cdd62a56a8bd0c8f09e20f3ae4cdd659ccbb2b18b90e81c4d`; `tools/estimation/est6opchar.c` sha256 `bab7a55043065ed689478f96420de6a698763c4eb4589881438562aff126f0c1`. - `est5` rerun: tool commit e9c2829, protocol sha256 `275cd5b72570d5182ef73d635e16775026e9d911e818b8e12f8300a701187af5`; params.txt of the rerun differs from the committed one only by the tool_commit line. +- Sections 3b, 4b, 5b tools (this change): `tools/estimation/est6dev.c` sha256 `3b18c7d211bf7d34b9ea18b1f78adf42d7292569d46f86d42c44db9d962a6230` (adds `plan6`, `g1sfull`, `twopiece-selfcheck`; + `g1sfull` was run from a binary built from exactly this file, sha256 of the binary `48251debc1680320ce2e79b933dfd04caba1881128168fa9c8592974c578a25b`), + `est6opchar.c` sha256 `3baf2cc2011e5a17726260ea89f7b241ad69ac263a276e8a5893279b267d8fbc` (adds case d), `est6opchar_table2.sh` sha256 `09ff006d69658a56f735132d25f00295bcb3f8d51221facbf52f2cc90658c823`. Estimation suites on this change (counts in the PR): + `make test-est6dev` 43 checks, PASS. +- Raw outputs: `docs/estimation/receipts/est-v6-dev/g1sfull-v5d1.txt` sha256 `d92b729dd439b064fa5a05438a26e1cae577d96f50b765eb4e5f174b4327ae23`, + `g1sfull-v3d1.txt` sha256 `ef258d6d05c86902c6007594a3547ae2c6c427b4a3461b0969119567cf970529`, + `opchar-table2.txt` sha256 `6749dc0eb14f9f79d618d9cce1377d75bd4f444dd026eb8511a13f04eb58aaef`. + +## 8. Freeze-readiness checklist (v6 NOT FROZEN) + +Status as of the commit that adds this section. DONE means the item exists and was checked as stated; OPEN means it does not exist +or is not decided. Nothing below is a freeze. + +| # | item | status | evidence | +|---|---|---|---| +| 1 | Model family decided (G1S adopted or dropped) | OPEN | development fit done (section 4b): G1S not preferred by the 0.01 nat rule on v5 D1 (-0.0015) or v3 D1 (+0.0023); outcome of the inner-band screen depends on how the ambiguous shrink rule is read (4b); load bias unresolved | +| 2 | Estimator library for the model (`est_v6.c`) with kappa 1.0 bit for bit equal to `est_v4.c` | OPEN | no `src/estimation/est_v6.c`; `est6dev g1sfull` holds a development two-piece (`twopiece-selfcheck` PASS; equals `est4_fast_logp` to 1.2e-11; kappa 1.0 path calls it unchanged) | +| 3 | Protocol text (`est-v6.md`) corrected and frozen | OPEN | proposal sha256 in section 7; known text defects to fix: seed rule (section 3 and 3b), inner band of P3 is zero width and the shrink of P4/P5 is ambiguous (4b), schedule lists | +| 4 | Parameter fit rules defined and implemented in development | DONE (development) | `est6dev g1sfull`: 55566 grid points, 5 kappa, 5-fold block CV, stage 2 with kappa_h, control; final refit equals the v5 G1 (-1.962811); raw outputs in `receipts/est-v6-dev/`. The final v6 parameters need v6 F data, which does not exist | +| 5 | Parameter fit on v6 F and committed | OPEN | F not collected (correctly: collection only after freeze) | +| 6 | Schedule identity rule (H1 differs from H2, deterministic, balanced) | DONE | rule SR-1, `est6dev plan6`, `make test-est6dev` (old rule collision reproduced, SR-1 distinct, determinism, balance, structure); PR #297 | +| 7 | Schedule identities written into the frozen file (F, H1, H2 segment lists, effective seeds) | OPEN | section 3b lists the SR-1 output for the declared seeds; adoption into the frozen file is a freeze edit | +| 8 | Tool identity: `est6` binary, `tool_commit`, source and protocol hashes, binding modes | OPEN | only development tools `est6dev` and `est6opchar` exist; they have no binding mode and no receipt writer; no `mk/estimation_v6.mk` | +| 9 | Scoring implementation: randomised PIT with a declared generator seed, bin and miss-rate gates, 99.5 % block bootstrap, three-way verdict, P1 to P10, baseline comparison | OPEN | `est6dev g1pit` computes descriptive statistics and a block bootstrap; `est6opchar` simulates the verdict logic on synthetic PIT; neither is the scorer | +| 10 | Operating-characteristics table required by v6 section 6 | DONE (as SIMULATION) | section 5 and 5b; false reject under (a) 0.7 % and pass under (b) 0.2 % at w 0.08, two runs; but conditional on assumptions (5b), so claim adequacy INCONCLUSIVE | +| 11 | Load-dependent calibration bias remedy | OPEN | quantified, not removed by G1S (4b); no remedy within the proposal | +| 12 | Collector and window protocol changes (section 4: /proc/stat foreign-CPU count, WINDOW_VOID, 300 s idle start) | OPEN | no `est6_collect.sh` | +| 13 | Data identities: D1 hashes recorded; v6 F, H1, H2 hash files | DONE (D1) / OPEN (F, H1, H2) | section 1 hashes; v6 raw data does not exist yet | +| 14 | D2 never read; refusal guard and its test | DONE | `forbidden_path` and the two SHA backstops in `est6dev.c`; tests `1`, `1b`, `g1sfull` refusals in `test_est6dev.sh`; `strace -f -e trace=openat` of a `g1sfull` run (stride 6) opened only the v5 D1 raw, marks and SHA256SUMS files and 0 paths containing the D2 date tag or "heldout"; the full runs and v3 D1 runs were given D1 and v3 D1 paths only and were not traced (UNVERIFIED beyond that) | +| 15 | Freeze commit, hashes recorded, receipts directory | OPEN | none | + +Not done by this appendix: items 1, 2, 3, 5, 7, 8, 9, 11, 12, 13 (F, H1, H2), 15. + diff --git a/docs/estimation/receipts/est-v6-dev/g1sfull-v3d1.txt b/docs/estimation/receipts/est-v6-dev/g1sfull-v3d1.txt new file mode 100644 index 000000000..ecf5f2ffd --- /dev/null +++ b/docs/estimation/receipts/est-v6-dev/g1sfull-v3d1.txt @@ -0,0 +1,69 @@ +input raw_sha256 9d5473b56dbb3765e5fc5335ef74aec47a11485651bcffc75272062ab48dc230 marks_sha256 4dfd06ec3f07c96eefe9697da2809634a0d4db2bfe4718909f2d0ca2c23d7a72 +label DEVELOPMENT RESULT (v5 D1 only; not a held-out result; v6 NOT FROZEN) +grid dyn 6 q 9 lam 7 nu 7 c 21 kappa 5 stride 1 points 55566 filter_failed 0 steps 2651 folds 5 +== G1S kappa free in {0.6..1.0} selection by 5-fold block CV, then stage 2 (ten-step) per fold +fold 0 steps 394 stage1 dyn 1 q 31622.8 lam 0.3 nu 1.5 c 0.60 kappa 0.9 train_mean_logscore -1.541231 oof_mean_logscore -1.861625 | stage2 phi 1 nu_h 0.7 c_h 0.45 kappa_h 0.6 +fold 1 steps 633 stage1 dyn 1 q 10000 lam 0.3 nu 1.5 c 0.65 kappa 0.9 train_mean_logscore -1.604770 oof_mean_logscore -1.551422 | stage2 phi 1 nu_h 0.8 c_h 0.55 kappa_h 0.7 +fold 2 steps 512 stage1 dyn 1 q 31622.8 lam 0.3 nu 1.5 c 0.60 kappa 0.9 train_mean_logscore -1.511848 oof_mean_logscore -1.910538 | stage2 phi 1 nu_h 0.7 c_h 0.45 kappa_h 0.6 +fold 3 steps 564 stage1 dyn 1 q 31622.8 lam 0.3 nu 1.5 c 0.60 kappa 0.9 train_mean_logscore -1.610034 oof_mean_logscore -1.510458 | stage2 phi 1 nu_h 0.7 c_h 0.45 kappa_h 0.7 +fold 4 steps 548 stage1 dyn 1 q 31622.8 lam 0.3 nu 1.5 c 0.65 kappa 0.9 train_mean_logscore -1.680994 oof_mean_logscore -1.239767 | stage2 phi 1 nu_h 0.7 c_h 0.55 kappa_h 0.6 +oof_pooled G1S mean_logscore -1.593744 +oof_pooled n 2651 pit_bin0 0.0929 pit_bin9 0.1041 lower_miss 0.0179 upper_miss 0.0304 cov50 0.4986 cov80 0.8030 cov95 0.9517 mean_u_minus_half 0.0003 mean_z_mid 0.0148 +oof_pooled_ten_step G1S n 2641 coverage95 0.9551 mean_logscore -3.433945 +oof_bins G1S 0.0929 0.1080 0.0975 0.1023 0.1042 0.1062 0.0932 0.0914 0.1002 0.1041 +oof_lag1_z_uncentred G1S -0.0241 over 2650 consecutive pairs +gate P1 cov50 value 0.4986 outer [0.460,0.540] PASS inner [0.470,0.530] PASS +gate P2 cov80 value 0.8030 outer [0.760,0.840] PASS inner [0.770,0.830] PASS +gate P3 cov95 value 0.9517 outer [0.930,0.970] PASS inner [0.950,0.950] FAIL +gate P4 lower_miss value 0.0179 outer [0.010,0.040] PASS inner [0.020,0.030] FAIL +gate P5 upper_miss value 0.0304 outer [0.010,0.040] PASS inner [0.020,0.030] FAIL +gate P6 bin0 value 0.0929 outer [0.070,0.130] PASS inner [0.080,0.120] PASS +gate P6 bin1 value 0.1080 outer [0.070,0.130] PASS inner [0.080,0.120] PASS +gate P6 bin2 value 0.0975 outer [0.070,0.130] PASS inner [0.080,0.120] PASS +gate P6 bin3 value 0.1023 outer [0.070,0.130] PASS inner [0.080,0.120] PASS +gate P6 bin4 value 0.1042 outer [0.070,0.130] PASS inner [0.080,0.120] PASS +gate P6 bin5 value 0.1062 outer [0.070,0.130] PASS inner [0.080,0.120] PASS +gate P6 bin6 value 0.0932 outer [0.070,0.130] PASS inner [0.080,0.120] PASS +gate P6 bin7 value 0.0914 outer [0.070,0.130] PASS inner [0.080,0.120] PASS +gate P6 bin8 value 0.1002 outer [0.070,0.130] PASS inner [0.080,0.120] PASS +gate P6 bin9 value 0.1041 outer [0.070,0.130] PASS inner [0.080,0.120] PASS +gate P7 ten_cov95 value 0.9551 outer [0.900,0.990] PASS inner [0.930,0.960] PASS +stratum G1S L0 blocks 4 steps 235 pit_bin0 0.1597(se 0.0171) pit_bin9 0.0844(se 0.0161) lower_miss 0.0644(se 0.0099) upper_miss 0.0410(se 0.0106) cov95 0.8946(se 0.0055) mean_u_minus_half -0.0883(se 0.0147) mean_z_mid -0.3028(se 0.0635) +stratum G1S L6 blocks 12 steps 672 pit_bin0 0.1752(se 0.0148) pit_bin9 0.1157(se 0.0120) lower_miss 0.0326(se 0.0050) upper_miss 0.0230(se 0.0044) cov95 0.9444(se 0.0057) mean_u_minus_half -0.0464(se 0.0149) mean_z_mid -0.1581(se 0.0538) +stratum G1S L12 blocks 16 steps 1079 pit_bin0 0.0562(se 0.0075) pit_bin9 0.1005(se 0.0124) lower_miss 0.0048(se 0.0016) upper_miss 0.0296(se 0.0074) cov95 0.9656(se 0.0075) mean_u_minus_half 0.0285(se 0.0079) mean_z_mid 0.1186(se 0.0312) +stratum G1S L18 blocks 7 steps 665 pit_bin0 0.0455(se 0.0054) pit_bin9 0.1054(se 0.0127) lower_miss 0.0078(se 0.0028) upper_miss 0.0355(se 0.0073) cov95 0.9567(se 0.0070) mean_u_minus_half 0.0333(se 0.0092) mean_z_mid 0.1333(se 0.0367) +== control kappa=1.0 (G1 exactly) selection by 5-fold block CV, then stage 2 (ten-step) per fold +fold 0 steps 394 stage1 dyn 1 q 31622.8 lam 0.3 nu 1.5 c 0.60 kappa 1.0 train_mean_logscore -1.544077 oof_mean_logscore -1.861708 | stage2 phi 1 nu_h 0.7 c_h 0.35 kappa_h 1.0 +fold 1 steps 633 stage1 dyn 1 q 10000 lam 0.3 nu 1.5 c 0.60 kappa 1.0 train_mean_logscore -1.606293 oof_mean_logscore -1.553813 | stage2 phi 1 nu_h 0.7 c_h 0.45 kappa_h 1.0 +fold 2 steps 512 stage1 dyn 1 q 31622.8 lam 0.3 nu 1.5 c 0.55 kappa 1.0 train_mean_logscore -1.514298 oof_mean_logscore -1.914361 | stage2 phi 1 nu_h 0.7 c_h 0.40 kappa_h 1.0 +fold 3 steps 564 stage1 dyn 1 q 31622.8 lam 0.3 nu 1.5 c 0.55 kappa 1.0 train_mean_logscore -1.612022 oof_mean_logscore -1.515863 | stage2 phi 1 nu_h 0.7 c_h 0.40 kappa_h 1.0 +fold 4 steps 548 stage1 dyn 1 q 31622.8 lam 0.3 nu 1.5 c 0.60 kappa 1.0 train_mean_logscore -1.683149 oof_mean_logscore -1.238747 | stage2 phi 1 nu_h 0.7 c_h 0.45 kappa_h 1.0 +oof_pooled G1ctl mean_logscore -1.596005 +oof_pooled n 2651 pit_bin0 0.0830 pit_bin9 0.1190 lower_miss 0.0166 upper_miss 0.0344 cov50 0.4965 cov80 0.7980 cov95 0.9490 mean_u_minus_half 0.0145 mean_z_mid 0.0629 +oof_pooled_ten_step G1ctl n 2641 coverage95 0.9684 mean_logscore -3.455092 +oof_bins G1ctl 0.0830 0.1048 0.0961 0.0984 0.1037 0.1051 0.0968 0.0909 0.1022 0.1190 +oof_lag1_z_uncentred G1ctl -0.0211 over 2650 consecutive pairs +gate P1 cov50 value 0.4965 outer [0.460,0.540] PASS inner [0.470,0.530] PASS +gate P2 cov80 value 0.7980 outer [0.760,0.840] PASS inner [0.770,0.830] PASS +gate P3 cov95 value 0.9490 outer [0.930,0.970] PASS inner [0.950,0.950] FAIL +gate P4 lower_miss value 0.0166 outer [0.010,0.040] PASS inner [0.020,0.030] FAIL +gate P5 upper_miss value 0.0344 outer [0.010,0.040] PASS inner [0.020,0.030] FAIL +gate P6 bin0 value 0.0830 outer [0.070,0.130] PASS inner [0.080,0.120] PASS +gate P6 bin1 value 0.1048 outer [0.070,0.130] PASS inner [0.080,0.120] PASS +gate P6 bin2 value 0.0961 outer [0.070,0.130] PASS inner [0.080,0.120] PASS +gate P6 bin3 value 0.0984 outer [0.070,0.130] PASS inner [0.080,0.120] PASS +gate P6 bin4 value 0.1037 outer [0.070,0.130] PASS inner [0.080,0.120] PASS +gate P6 bin5 value 0.1051 outer [0.070,0.130] PASS inner [0.080,0.120] PASS +gate P6 bin6 value 0.0968 outer [0.070,0.130] PASS inner [0.080,0.120] PASS +gate P6 bin7 value 0.0909 outer [0.070,0.130] PASS inner [0.080,0.120] PASS +gate P6 bin8 value 0.1022 outer [0.070,0.130] PASS inner [0.080,0.120] PASS +gate P6 bin9 value 0.1190 outer [0.070,0.130] PASS inner [0.080,0.120] PASS +gate P7 ten_cov95 value 0.9684 outer [0.900,0.990] PASS inner [0.930,0.960] FAIL +stratum G1ctl L0 blocks 4 steps 235 pit_bin0 0.1486(se 0.0195) pit_bin9 0.0890(se 0.0174) lower_miss 0.0597(se 0.0066) upper_miss 0.0438(se 0.0111) cov95 0.8965(se 0.0051) mean_u_minus_half -0.0702(se 0.0145) mean_z_mid -0.2402(se 0.0639) +stratum G1ctl L6 blocks 12 steps 672 pit_bin0 0.1582(se 0.0130) pit_bin9 0.1343(se 0.0135) lower_miss 0.0303(se 0.0050) upper_miss 0.0259(se 0.0047) cov95 0.9438(se 0.0056) mean_u_minus_half -0.0300(se 0.0150) mean_z_mid -0.0954(se 0.0542) +stratum G1ctl L12 blocks 16 steps 1079 pit_bin0 0.0485(se 0.0070) pit_bin9 0.1166(se 0.0131) lower_miss 0.0042(se 0.0016) upper_miss 0.0344(se 0.0084) cov95 0.9613(se 0.0086) mean_u_minus_half 0.0413(se 0.0085) mean_z_mid 0.1598(se 0.0336) +stratum G1ctl L18 blocks 7 steps 665 pit_bin0 0.0399(se 0.0053) pit_bin9 0.1180(se 0.0116) lower_miss 0.0077(se 0.0028) upper_miss 0.0396(se 0.0070) cov95 0.9528(se 0.0068) mean_u_minus_half 0.0458(se 0.0095) mean_z_mid 0.1726(se 0.0372) +== final whole-pool refit (stage 1; same grid) +final G1S dyn 1 q 31622.8 lam 0.3 nu 1.5 c 0.60 kappa 0.9 in_sample_mean_logscore -1.588849 +final control dyn 1 q 31622.8 lam 0.3 nu 1.5 c 0.60 kappa 1.0 in_sample_mean_logscore -1.591284 +tie_rule G1S preferred over G1 only if out-of-fold log score exceeds the control by more than 0.01 nats diff --git a/docs/estimation/receipts/est-v6-dev/g1sfull-v5d1.txt b/docs/estimation/receipts/est-v6-dev/g1sfull-v5d1.txt new file mode 100644 index 000000000..8cac544f8 --- /dev/null +++ b/docs/estimation/receipts/est-v6-dev/g1sfull-v5d1.txt @@ -0,0 +1,69 @@ +input raw_sha256 7da6e4950c333bae65e5663c32c9cfe9de6657f0ff88c55e9b9e767152634465 marks_sha256 6cd7fda33d877a07e6fd21423f0ebc425c616c4d029f3575165ed6e32a02f748 +label DEVELOPMENT RESULT (v5 D1 only; not a held-out result; v6 NOT FROZEN) +grid dyn 6 q 9 lam 7 nu 7 c 21 kappa 5 stride 1 points 55566 filter_failed 0 steps 2652 folds 5 +== G1S kappa free in {0.6..1.0} selection by 5-fold block CV, then stage 2 (ten-step) per fold +fold 0 steps 470 stage1 dyn 1 q 10000 lam 0.1 nu 1.25 c 0.70 kappa 1.0 train_mean_logscore -2.016391 oof_mean_logscore -1.714066 | stage2 phi 0.95 nu_h 0.8 c_h 0.20 kappa_h 1.0 +fold 1 steps 692 stage1 dyn 1 q 31622.8 lam 0.1 nu 1.25 c 0.70 kappa 1.0 train_mean_logscore -1.961478 oof_mean_logscore -1.984311 | stage2 phi 0.95 nu_h 0.8 c_h 0.20 kappa_h 1.0 +fold 2 steps 845 stage1 dyn 1 q 10000 lam 0.1 nu 1.25 c 0.70 kappa 0.9 train_mean_logscore -1.938085 oof_mean_logscore -2.016194 | stage2 phi 0.95 nu_h 0.8 c_h 0.25 kappa_h 0.8 +fold 3 steps 299 stage1 dyn 1 q 10000 lam 0.1 nu 1.25 c 0.70 kappa 0.9 train_mean_logscore -1.930429 oof_mean_logscore -2.219070 | stage2 phi 0.95 nu_h 0.8 c_h 0.20 kappa_h 1.0 +fold 4 steps 346 stage1 dyn 1 q 10000 lam 0.1 nu 1.25 c 0.70 kappa 1.0 train_mean_logscore -1.963521 oof_mean_logscore -1.958083 | stage2 phi 0.95 nu_h 0.8 c_h 0.20 kappa_h 1.0 +oof_pooled G1S mean_logscore -1.969622 +oof_pooled n 2652 pit_bin0 0.0853 pit_bin9 0.1199 lower_miss 0.0138 upper_miss 0.0340 cov50 0.4943 cov80 0.7947 cov95 0.9522 mean_u_minus_half -0.0006 mean_z_mid 0.0224 +oof_pooled_ten_step G1S n 2642 coverage95 0.9410 mean_logscore -3.740472 +oof_bins G1S 0.0853 0.1221 0.0988 0.0962 0.1059 0.1091 0.0948 0.0809 0.0870 0.1199 +oof_lag1_z_uncentred G1S -0.0211 over 2651 consecutive pairs +gate P1 cov50 value 0.4943 outer [0.460,0.540] PASS inner [0.470,0.530] PASS +gate P2 cov80 value 0.7947 outer [0.760,0.840] PASS inner [0.770,0.830] PASS +gate P3 cov95 value 0.9522 outer [0.930,0.970] PASS inner [0.950,0.950] FAIL +gate P4 lower_miss value 0.0138 outer [0.010,0.040] PASS inner [0.020,0.030] FAIL +gate P5 upper_miss value 0.0340 outer [0.010,0.040] PASS inner [0.020,0.030] FAIL +gate P6 bin0 value 0.0853 outer [0.070,0.130] PASS inner [0.080,0.120] PASS +gate P6 bin1 value 0.1221 outer [0.070,0.130] PASS inner [0.080,0.120] FAIL +gate P6 bin2 value 0.0988 outer [0.070,0.130] PASS inner [0.080,0.120] PASS +gate P6 bin3 value 0.0962 outer [0.070,0.130] PASS inner [0.080,0.120] PASS +gate P6 bin4 value 0.1059 outer [0.070,0.130] PASS inner [0.080,0.120] PASS +gate P6 bin5 value 0.1091 outer [0.070,0.130] PASS inner [0.080,0.120] PASS +gate P6 bin6 value 0.0948 outer [0.070,0.130] PASS inner [0.080,0.120] PASS +gate P6 bin7 value 0.0809 outer [0.070,0.130] PASS inner [0.080,0.120] PASS +gate P6 bin8 value 0.0870 outer [0.070,0.130] PASS inner [0.080,0.120] PASS +gate P6 bin9 value 0.1199 outer [0.070,0.130] PASS inner [0.080,0.120] PASS +gate P7 ten_cov95 value 0.9410 outer [0.900,0.990] PASS inner [0.930,0.960] PASS +stratum G1S L0 blocks 8 steps 818 pit_bin0 0.1286(se 0.0067) pit_bin9 0.0754(se 0.0082) lower_miss 0.0323(se 0.0079) upper_miss 0.0354(se 0.0044) cov95 0.9323(se 0.0083) mean_u_minus_half -0.0704(se 0.0081) mean_z_mid -0.2152(se 0.0339) +stratum G1S L6 blocks 10 steps 739 pit_bin0 0.1293(se 0.0089) pit_bin9 0.1087(se 0.0065) lower_miss 0.0136(se 0.0040) upper_miss 0.0164(se 0.0057) cov95 0.9700(se 0.0080) mean_u_minus_half -0.0271(se 0.0102) mean_z_mid -0.0784(se 0.0341) +stratum G1S L12 blocks 14 steps 970 pit_bin0 0.0263(se 0.0067) pit_bin9 0.1578(se 0.0138) lower_miss 0.0002(se 0.0002) upper_miss 0.0399(se 0.0058) cov95 0.9599(se 0.0058) mean_u_minus_half 0.0627(se 0.0103) mean_z_mid 0.2423(se 0.0363) +stratum G1S L18 blocks 3 steps 125 pit_bin0 0.0009(se 0.0008) pit_bin9 0.1834(se 0.0253) lower_miss 0.0000(se 0.0000) upper_miss 0.0828(se 0.0201) cov95 0.9172(se 0.0201) mean_u_minus_half 0.1211(se 0.0158) mean_z_mid 0.4662(se 0.0652) +== control kappa=1.0 (G1 exactly) selection by 5-fold block CV, then stage 2 (ten-step) per fold +fold 0 steps 470 stage1 dyn 1 q 10000 lam 0.1 nu 1.25 c 0.70 kappa 1.0 train_mean_logscore -2.016391 oof_mean_logscore -1.714066 | stage2 phi 0.95 nu_h 0.8 c_h 0.20 kappa_h 1.0 +fold 1 steps 692 stage1 dyn 1 q 31622.8 lam 0.1 nu 1.25 c 0.70 kappa 1.0 train_mean_logscore -1.961478 oof_mean_logscore -1.984311 | stage2 phi 0.95 nu_h 0.8 c_h 0.20 kappa_h 1.0 +fold 2 steps 845 stage1 dyn 1 q 10000 lam 0.1 nu 1.25 c 0.70 kappa 1.0 train_mean_logscore -1.940261 oof_mean_logscore -2.011034 | stage2 phi 0.95 nu_h 0.8 c_h 0.20 kappa_h 1.0 +fold 3 steps 299 stage1 dyn 1 q 10000 lam 0.1 nu 1.25 c 0.65 kappa 1.0 train_mean_logscore -1.930450 oof_mean_logscore -2.220702 | stage2 phi 0.95 nu_h 0.8 c_h 0.20 kappa_h 1.0 +fold 4 steps 346 stage1 dyn 1 q 10000 lam 0.1 nu 1.25 c 0.70 kappa 1.0 train_mean_logscore -1.963521 oof_mean_logscore -1.958083 | stage2 phi 0.95 nu_h 0.8 c_h 0.20 kappa_h 1.0 +oof_pooled G1ctl mean_logscore -1.968162 +oof_pooled n 2652 pit_bin0 0.0766 pit_bin9 0.1233 lower_miss 0.0126 upper_miss 0.0356 cov50 0.5003 cov80 0.8001 cov95 0.9518 mean_u_minus_half 0.0064 mean_z_mid 0.0467 +oof_pooled_ten_step G1ctl n 2642 coverage95 0.9402 mean_logscore -3.728084 +oof_bins G1ctl 0.0766 0.1190 0.1005 0.0973 0.1058 0.1095 0.0979 0.0823 0.0878 0.1233 +oof_lag1_z_uncentred G1ctl -0.0240 over 2651 consecutive pairs +gate P1 cov50 value 0.5003 outer [0.460,0.540] PASS inner [0.470,0.530] PASS +gate P2 cov80 value 0.8001 outer [0.760,0.840] PASS inner [0.770,0.830] PASS +gate P3 cov95 value 0.9518 outer [0.930,0.970] PASS inner [0.950,0.950] FAIL +gate P4 lower_miss value 0.0126 outer [0.010,0.040] PASS inner [0.020,0.030] FAIL +gate P5 upper_miss value 0.0356 outer [0.010,0.040] PASS inner [0.020,0.030] FAIL +gate P6 bin0 value 0.0766 outer [0.070,0.130] PASS inner [0.080,0.120] FAIL +gate P6 bin1 value 0.1190 outer [0.070,0.130] PASS inner [0.080,0.120] PASS +gate P6 bin2 value 0.1005 outer [0.070,0.130] PASS inner [0.080,0.120] PASS +gate P6 bin3 value 0.0973 outer [0.070,0.130] PASS inner [0.080,0.120] PASS +gate P6 bin4 value 0.1058 outer [0.070,0.130] PASS inner [0.080,0.120] PASS +gate P6 bin5 value 0.1095 outer [0.070,0.130] PASS inner [0.080,0.120] PASS +gate P6 bin6 value 0.0979 outer [0.070,0.130] PASS inner [0.080,0.120] PASS +gate P6 bin7 value 0.0823 outer [0.070,0.130] PASS inner [0.080,0.120] PASS +gate P6 bin8 value 0.0878 outer [0.070,0.130] PASS inner [0.080,0.120] PASS +gate P6 bin9 value 0.1233 outer [0.070,0.130] PASS inner [0.080,0.120] FAIL +gate P7 ten_cov95 value 0.9402 outer [0.900,0.990] PASS inner [0.930,0.960] PASS +stratum G1ctl L0 blocks 8 steps 818 pit_bin0 0.1149(se 0.0096) pit_bin9 0.0766(se 0.0083) lower_miss 0.0309(se 0.0083) upper_miss 0.0359(se 0.0043) cov95 0.9331(se 0.0087) mean_u_minus_half -0.0611(se 0.0096) mean_z_mid -0.1839(se 0.0400) +stratum G1ctl L6 blocks 10 steps 739 pit_bin0 0.1144(se 0.0072) pit_bin9 0.1181(se 0.0074) lower_miss 0.0106(se 0.0032) upper_miss 0.0192(se 0.0061) cov95 0.9702(se 0.0069) mean_u_minus_half -0.0156(se 0.0086) mean_z_mid -0.0366(se 0.0288) +stratum G1ctl L12 blocks 14 steps 970 pit_bin0 0.0252(se 0.0070) pit_bin9 0.1589(se 0.0140) lower_miss 0.0002(se 0.0002) upper_miss 0.0406(se 0.0061) cov95 0.9592(se 0.0061) mean_u_minus_half 0.0647(se 0.0111) mean_z_mid 0.2481(se 0.0386) +stratum G1ctl L18 blocks 3 steps 125 pit_bin0 0.0003(se 0.0003) pit_bin9 0.1843(se 0.0255) lower_miss 0.0000(se 0.0000) upper_miss 0.0913(se 0.0259) cov95 0.9087(se 0.0259) mean_u_minus_half 0.1268(se 0.0181) mean_z_mid 0.4854(se 0.0743) +== final whole-pool refit (stage 1; same grid) +final G1S dyn 1 q 10000 lam 0.1 nu 1.25 c 0.70 kappa 1.0 in_sample_mean_logscore -1.962811 +final control dyn 1 q 10000 lam 0.1 nu 1.25 c 0.70 kappa 1.0 in_sample_mean_logscore -1.962811 +tie_rule G1S preferred over G1 only if out-of-fold log score exceeds the control by more than 0.01 nats diff --git a/docs/estimation/receipts/est-v6-dev/opchar-table2.txt b/docs/estimation/receipts/est-v6-dev/opchar-table2.txt new file mode 100644 index 000000000..42888a24e --- /dev/null +++ b/docs/estimation/receipts/est-v6-dev/opchar-table2.txt @@ -0,0 +1,22 @@ +# (d) regime-dependent PIT (v5 D1 per-level shares), runs 2 and 3 +case d bin0 0.0760 runs 2 w 0.080 rho10 0.900 reps 20000 seed 0xe6a001 PASS 0.0656 NOT_ESTABLISHED 0.8536 HELD_OUT_FAIL 0.0809 (counts 1312 17071 1617; Monte Carlo SE at most 0.0035) +case d bin0 0.0760 runs 3 w 0.080 rho10 0.900 reps 20000 seed 0xe6a001 PASS 0.0475 NOT_ESTABLISHED 0.8518 HELD_OUT_FAIL 0.1007 (counts 950 17036 2014; Monte Carlo SE at most 0.0035) +case d bin0 0.0760 runs 2 w 0.120 rho10 0.900 reps 20000 seed 0xe6a001 PASS 0.0726 NOT_ESTABLISHED 0.8061 HELD_OUT_FAIL 0.1214 (counts 1451 16121 2428; Monte Carlo SE at most 0.0035) +case d bin0 0.0760 runs 3 w 0.120 rho10 0.900 reps 20000 seed 0xe6a001 PASS 0.0592 NOT_ESTABLISHED 0.8327 HELD_OUT_FAIL 0.1081 (counts 1185 16653 2162; Monte Carlo SE at most 0.0035) +# replication of (a) and (b) under seed 0xE6A777 (table 1 used 0xE6A001) +case a bin0 0.0760 runs 2 w 0.080 rho10 0.900 reps 20000 seed 0xe6a777 PASS 0.9931 NOT_ESTABLISHED 0.0069 HELD_OUT_FAIL 0.0000 (counts 19862 138 0; Monte Carlo SE at most 0.0035) +case a bin0 0.0760 runs 3 w 0.080 rho10 0.900 reps 20000 seed 0xe6a777 PASS 0.9988 NOT_ESTABLISHED 0.0013 HELD_OUT_FAIL 0.0000 (counts 19975 25 0; Monte Carlo SE at most 0.0035) +case b bin0 0.0760 runs 2 w 0.080 rho10 0.900 reps 20000 seed 0xe6a777 PASS 0.0017 NOT_ESTABLISHED 0.5644 HELD_OUT_FAIL 0.4339 (counts 34 11288 8678; Monte Carlo SE at most 0.0035) +case b bin0 0.0760 runs 3 w 0.080 rho10 0.900 reps 20000 seed 0xe6a777 PASS 0.0003 NOT_ESTABLISHED 0.3752 HELD_OUT_FAIL 0.6244 (counts 7 7505 12488; Monte Carlo SE at most 0.0035) +# false accept: true bin 0 below the 0.07 limit, runs 2 and 3, w 0.08 +case c bin0 0.0700 runs 2 w 0.080 rho10 0.900 reps 20000 seed 0xe6a001 PASS 0.4030 NOT_ESTABLISHED 0.5869 HELD_OUT_FAIL 0.0101 (counts 8060 11738 202; Monte Carlo SE at most 0.0035) +case c bin0 0.0700 runs 3 w 0.080 rho10 0.900 reps 20000 seed 0xe6a001 PASS 0.4417 NOT_ESTABLISHED 0.5516 HELD_OUT_FAIL 0.0066 (counts 8835 11032 133; Monte Carlo SE at most 0.0035) +case c bin0 0.0680 runs 2 w 0.080 rho10 0.900 reps 20000 seed 0xe6a001 PASS 0.2939 NOT_ESTABLISHED 0.6851 HELD_OUT_FAIL 0.0210 (counts 5879 13701 420; Monte Carlo SE at most 0.0035) +case c bin0 0.0680 runs 3 w 0.080 rho10 0.900 reps 20000 seed 0xe6a001 PASS 0.2996 NOT_ESTABLISHED 0.6816 HELD_OUT_FAIL 0.0187 (counts 5992 13633 375; Monte Carlo SE at most 0.0035) +case c bin0 0.0650 runs 2 w 0.080 rho10 0.900 reps 20000 seed 0xe6a001 PASS 0.1517 NOT_ESTABLISHED 0.7930 HELD_OUT_FAIL 0.0554 (counts 3033 15860 1107; Monte Carlo SE at most 0.0035) +case c bin0 0.0650 runs 3 w 0.080 rho10 0.900 reps 20000 seed 0xe6a001 PASS 0.1252 NOT_ESTABLISHED 0.8066 HELD_OUT_FAIL 0.0682 (counts 2503 16133 1364; Monte Carlo SE at most 0.0035) +case c bin0 0.0600 runs 2 w 0.080 rho10 0.900 reps 20000 seed 0xe6a001 PASS 0.0271 NOT_ESTABLISHED 0.7607 HELD_OUT_FAIL 0.2122 (counts 541 15214 4245; Monte Carlo SE at most 0.0035) +case c bin0 0.0600 runs 3 w 0.080 rho10 0.900 reps 20000 seed 0xe6a001 PASS 0.0124 NOT_ESTABLISHED 0.6769 HELD_OUT_FAIL 0.3106 (counts 249 13538 6213; Monte Carlo SE at most 0.0035) +case c bin0 0.0550 runs 2 w 0.080 rho10 0.900 reps 20000 seed 0xe6a001 PASS 0.0015 NOT_ESTABLISHED 0.4701 HELD_OUT_FAIL 0.5284 (counts 31 9401 10568; Monte Carlo SE at most 0.0035) +case c bin0 0.0550 runs 3 w 0.080 rho10 0.900 reps 20000 seed 0xe6a001 PASS 0.0004 NOT_ESTABLISHED 0.2816 HELD_OUT_FAIL 0.7180 (counts 8 5631 14361; Monte Carlo SE at most 0.0035) +[exited with code 0] diff --git a/mk/.crumb b/mk/.crumb index 0cdc8aaa4..716798072 100644 --- a/mk/.crumb +++ b/mk/.crumb @@ -7,14 +7,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-05T16:20:55Z", + "compiled_at": "2026-10-05T16:48:41Z", "compiler": "crumb-compile/1", - "digest": "sha256:2b9abab41d977b59a4c2028721f9eed109694da67caee74a589b795891995ac2", + "digest": "sha256:7a280ae41e1051f14529ab2c8b2749f4712ea37df87254fd90bfbc3e1bba2048", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 56, - "generated_at_commit": "bfe4be858d65d5441ee98434945db8fe816dfeff", - "source_tree": "sha256:d60b5d1ed2cd03e424d9600aa1449b40a16e2276aea3958d197c0f41f8dc213d" + "generated_at_commit": "678ed89f7b0213130c92d20d481bf429414772e2", + "source_tree": "sha256:0fcc8e338cb26be5ab3c9d7d009c5cb65055a68e4e20ccaab359691ac79afc78" }, "owner_lane": "", "provenance": { diff --git a/mk/estimation_v6dev.mk b/mk/estimation_v6dev.mk index 1d0731c29..142fcbfc8 100644 --- a/mk/estimation_v6dev.mk +++ b/mk/estimation_v6dev.mk @@ -6,10 +6,11 @@ # est6opchar operating-characteristics simulation (reads no data file) # test-est6dev tests for both (D1 development data and synthetic only; held-out refusals) # est6-opchar-table prints the appendix operating-characteristics table (about 3 minutes) +# est6-opchar-table2 prints the appendix section 5b SIMULATION table (regime case, replication, false accept) ifndef ESTIMATION_V6DEV_MK ESTIMATION_V6DEV_MK := 1 include mk/estimation_v4.mk -.PHONY: est6dev est6opchar test-est6dev est6-opchar-table +.PHONY: est6dev est6opchar test-est6dev est6-opchar-table est6-opchar-table2 ESTV6D_DIR = $(OUT_DIR)/estimation-v6dev ESTV6D_SRCS = tools/estimation/est6dev.c tools/estimation/est3c_common.c tools/estimation/est_replay.c \ src/estimation/est_v4.c src/estimation/est_pred.c src/estimation/est_mix.c $(EST_KF_SRCS) @@ -26,4 +27,6 @@ test-est6dev: $(ESTV6D_DIR)/est6dev $(ESTV6D_DIR)/est6opchar sh tools/estimation/test_est6dev.sh $(ESTV6D_DIR)/est6dev $(ESTV6D_DIR)/est6opchar est6-opchar-table: $(ESTV6D_DIR)/est6opchar sh tools/estimation/est6opchar_table.sh $(ESTV6D_DIR)/est6opchar 4000 +est6-opchar-table2: $(ESTV6D_DIR)/est6opchar + sh tools/estimation/est6opchar_table2.sh $(ESTV6D_DIR)/est6opchar 20000 endif diff --git a/tools/.crumb b/tools/.crumb index 2c2981330..ca20b6a02 100644 --- a/tools/.crumb +++ b/tools/.crumb @@ -43,8 +43,8 @@ "purpose": "Runner for the DUAL applicability experiment: runs the pre-registered campaign and writes result" }, { - "digest": "38788064b345d8de8180cf536f5ad4419044db9efe9e7d7645fe83ba77740769", - "last_commit": "c847a16", + "digest": "11eb4960ad04fe5bd01ee9d2bbb6900712176c0991ecc0b02b3204ac60248eeb", + "last_commit": "8fd3afe", "name": "estimation", "purpose": "Directory tools/estimation. Purpose not yet described by a human." }, @@ -55,15 +55,15 @@ "purpose": "Directory tools/turing_verify_indep. Purpose not yet described by a human." } ], - "children_root": "sha256:a66a2b519c9bfbaea8225c349d1cdbdefcdbfb79f4bbc39277d952b7143a98e8", - "compiled_at": "2026-10-05T16:36:21Z", + "children_root": "sha256:8a042dc49a250f0d1b7ae1358fc70bf7bdc9eff651a5ff7c9ee41fd49d329041", + "compiled_at": "2026-10-05T16:48:41Z", "compiler": "crumb-compile/1", - "digest": "sha256:1987becea7850243107a1e552c1a279bc4fca82a7a94c7b2b4c540cdf06fee35", + "digest": "sha256:39a4a935c81a9ba2a047be53e745857892c48a9c9e17f5f166e037d36f7a28b6", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 133, - "generated_at_commit": "c847a167bdaeb6e2dc997a46c37057639bb39412", - "source_tree": "sha256:a1b365dbfedc41fbe312faada3f1050ba68a85bd14460b315d0c8501f732ce2a" + "files": 134, + "generated_at_commit": "678ed89f7b0213130c92d20d481bf429414772e2", + "source_tree": "sha256:d47b5eda2ca06c7cfafa2cdc13145fc3d587cffaa5c87b765626c7bd06d922ae" }, "owner_lane": "", "provenance": { diff --git a/tools/estimation/.crumb b/tools/estimation/.crumb index 843ea8cdd..dcbfe45e8 100644 --- a/tools/estimation/.crumb +++ b/tools/estimation/.crumb @@ -7,14 +7,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-05T14:59:30Z", + "compiled_at": "2026-10-05T15:40:51Z", "compiler": "crumb-compile/1", - "digest": "sha256:38788064b345d8de8180cf536f5ad4419044db9efe9e7d7645fe83ba77740769", + "digest": "sha256:11eb4960ad04fe5bd01ee9d2bbb6900712176c0991ecc0b02b3204ac60248eeb", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 29, - "generated_at_commit": "a386d65ed193a02dccac444de3fd3224c96162b4", - "source_tree": "sha256:08afcc137381f31ec3c4e0c9a6c733d4ac21b6569b2a2c9571a935bf554f6df1" + "files": 30, + "generated_at_commit": "25311c0c2aee4eb4991052115d9ad91f5b4d2a1e", + "source_tree": "sha256:62685b60618f0ae080c36abb802a1414f249007806a1498db95f66fa1d97206a" }, "owner_lane": "", "provenance": { diff --git a/tools/estimation/est6dev.c b/tools/estimation/est6dev.c index 1a80fc444..7311c6bfc 100644 --- a/tools/estimation/est6dev.c +++ b/tools/estimation/est6dev.c @@ -25,6 +25,15 @@ #include "est3c_common.h" #include "est_v4.h" +/* Allocation failure stops the tool with a message (no partial result is written). */ +static void *xalloc(void *p, const char *what) +{ + if (!p) { fprintf(stderr, "est6dev: out of memory (%s)\n", what); exit(2); } + return p; +} +#define XMALLOC(n) xalloc(malloc(n), __func__) +#define XCALLOC(n, s) xalloc(calloc((n), (s)), __func__) + #define D2_DATE_TAG "20261005T112838Z" #define D2_RAW_SHA "7dda21f664587c4401326c3082f28039e133ba5627c8564678f259e2d7036ff0" #define D2_MARKS_SHA "95879ed909b8fec1207695dc1093b24be56f00563cd364c62bd30007b0dc26bb" @@ -233,8 +242,8 @@ static est_obs_class classify(const c3_tick *t, est_pobs *ob) static int run_g1(const c3_ticks *tk, const est4_params *p, step_t **out, size_t *nout, size_t *unscorable) { est4_state s; - est_dpred *dp = malloc(sizeof *dp); - step_t *st = malloc((tk->n ? tk->n : 1) * sizeof *st); + est_dpred *dp = XMALLOC(sizeof *dp); + step_t *st = XMALLOC((tk->n ? tk->n : 1) * sizeof *st); size_t n = 0; *unscorable = 0; if (!dp || !st) return 1; if (est4_init(p, &s) != EST_OK) return 1; @@ -348,8 +357,8 @@ static int cmd_g1pit(int argc, char **argv) /* per-step contributions, per-block sums */ size_t nb_max = 2 * mk.n + 2; - double (*bs)[NSTAT] = calloc(nb_max, sizeof *bs); - double *bn = calloc(nb_max, sizeof *bn); + double (*bs)[NSTAT] = XCALLOC(nb_max, sizeof *bs); + double *bn = XCALLOC(nb_max, sizeof *bn); double tot[NSTAT] = { 0 }; double zsum = 0; if (!bs || !bn) return 1; @@ -367,7 +376,7 @@ static int cmd_g1pit(int argc, char **argv) printf("mean_z_midpit %.6f\n", zm); /* blocks that have steps */ - size_t nb = 0, nload = 0, *idx = malloc(nb_max * sizeof *idx); + size_t nb = 0, nload = 0, *idx = XMALLOC(nb_max * sizeof *idx); for (size_t b = 0; b < nb_max; b++) if (bn[b] > 0) { idx[nb++] = b; nload += (b & 1u); } printf("blocks %zu (loaded %zu, idle %zu) mean_steps_per_block %.1f\n", nb, nload, nb - nload, (double)n / (double)nb); if (show_blocks) @@ -390,7 +399,7 @@ static int cmd_g1pit(int argc, char **argv) if (ln[li] > 0) printf("by_level L%d steps %.0f pit_bin0 %.4f pit_bin9 %.4f lower_miss %.4f upper_miss %.4f\n", lvn[li], ln[li], ls[li][0] / ln[li], ls[li][9] / ln[li], ls[li][10] / ln[li], ls[li][11] / ln[li]); } /* bootstrap: resample whole blocks with replacement; ratio estimator */ - double *draw = malloc((size_t)boot * NSTAT * sizeof(double)); + double *draw = XMALLOC((size_t)boot * NSTAT * sizeof(double)); if (!draw) return 1; uint64_t rng = seed; for (int r = 0; r < boot; r++) { @@ -404,7 +413,7 @@ static int cmd_g1pit(int argc, char **argv) } printf("bootstrap draws %d seed 0x%llx unit whole_blocks\n", boot, (unsigned long long)seed); printf("# stat value iid_se boot_se design_effect ci95_lo ci95_hi ci995_lo ci995_hi\n"); - double *col = malloc((size_t)boot * sizeof *col); + double *col = XMALLOC((size_t)boot * sizeof *col); for (int k = 0; k < NSTAT; k++) { double val = tot[k] / (double)n, mean = 0, var = 0; for (int r = 0; r < boot; r++) { col[r] = draw[(size_t)r * NSTAT + k]; mean += col[r]; } @@ -432,7 +441,7 @@ typedef struct { int64_t t; double y, m, b, anchor; } trace_t; static int run_g1_trace(const c3_ticks *tk, const est4_params *p, trace_t **out, size_t *nout) { est4_state s; - trace_t *tr = malloc((tk->n ? tk->n : 1) * sizeof *tr); + trace_t *tr = XMALLOC((tk->n ? tk->n : 1) * sizeof *tr); size_t n = 0; if (!tr || est4_init(p, &s) != EST_OK) return 1; long first = -1; @@ -525,16 +534,16 @@ static int cmd_g1s(int argc, char **argv) if (run_g1_trace(&tk, &p, &tr, &n) || n == 0) { fprintf(stderr, "g1 trace failed\n"); return 1; } /* fold of a step = rank of its block among blocks that have steps, modulo nfold */ size_t nb_max = 2 * mk.n + 2; - int *rank = malloc(nb_max * sizeof *rank), *seen = calloc(nb_max, sizeof *seen); - size_t *blk = malloc(n * sizeof *blk); + int *rank = XMALLOC(nb_max * sizeof *rank), *seen = XCALLOC(nb_max, sizeof *seen); + size_t *blk = XMALLOC(n * sizeof *blk); for (size_t i = 0; i < n; i++) { blk[i] = block_of(&mk, tr[i].t); seen[blk[i]] = 1; } int nr = 0; for (size_t b = 0; b < nb_max; b++) rank[b] = seen[b] ? nr++ : -1; - int *fold = malloc(n * sizeof *fold); + int *fold = XMALLOC(n * sizeof *fold); for (size_t i = 0; i < n; i++) fold[i] = rank[blk[i]] % nfold; /* per grid point, per step: logp, F_lo, F_hi */ size_t G = (size_t)NK * NCG; - double *lp = malloc(G * n * sizeof *lp), *Flo = malloc(G * n * sizeof *Flo), *Fhi = malloc(G * n * sizeof *Fhi); + double *lp = XMALLOC(G * n * sizeof *lp), *Flo = XMALLOC(G * n * sizeof *Flo), *Fhi = XMALLOC(G * n * sizeof *Fhi); if (!lp || !Flo || !Fhi) return 1; for (int ki = 0; ki < NK; ki++) for (int ci = 0; ci < NCG; ci++) { @@ -603,14 +612,494 @@ static int cmd_g1s(int argc, char **argv) return 0; } + +/* ------------------------------------------------------------ G1S full fit (item 2, DEVELOPMENT only) */ +/* est-v6.md section 5: G1 grid (dyn q lam nu c; lam grid extended downwards by 0.05 as section 5.5 says) times + * kappa in {0.6..1.0}, 5-fold block cross-validation (fold = rank of the block among load segments and idle + * stretches, modulo 5), selection by the pooled out-of-fold one-step mean log score; stage 2 (phi nu_h c_h + * kappa_h) per fold on the training folds with stage 1 frozen; a control with kappa = 1.0 (G1 exactly: that + * code path calls the unchanged est4_fast_logp) is fitted under the same scheme and folds. Reads D1 only. */ +#define NKS 5 +#define NLAMX 7 +#define NDYN 6 +#define NQX 9 +#define NNU 7 +#define NCX 21 +static const double LAMX[NLAMX] = { 0.05, 0.1, 0.2, 0.3, 0.5, 0.7, 0.9 }; +static const double DYNX[NDYN] = { 0.5, 1, 2, 4, 10, 30 }; +static const double NUX[NNU] = { 0.8, 1, 1.25, 1.5, 2, 3, 5 }; +static const double PHIX[5] = { 1, 0.95, 0.9, 0.8, 0.6 }; +static const double NUHX[10] = { 0.5, 0.6, 0.7, 0.8, 1, 1.25, 1.5, 2, 3, 5 }; +#define NCHX 31 + +typedef struct { + size_t n1, n10; + int64_t *t1, *t10; + double *y1, *m1, *b1, *a1; + double *y10, *m10, *v10, *g10, *gl10, *a10; +} tr2_t; + +static int tr2_alloc(tr2_t *r, size_t cap) +{ + memset(r, 0, sizeof *r); + cap = cap ? cap : 1; + double **f[10] = { &r->y1, &r->m1, &r->b1, &r->a1, &r->y10, &r->m10, &r->v10, &r->g10, &r->gl10, &r->a10 }; + for (int i = 0; i < 10; i++) if (!(*f[i] = malloc(cap * sizeof(double)))) return 1; + r->t1 = XMALLOC(cap * sizeof(int64_t)); r->t10 = XMALLOC(cap * sizeof(int64_t)); + return !(r->t1 && r->t10); +} +static void tr2_free(tr2_t *r) +{ + free(r->y1); free(r->m1); free(r->b1); free(r->a1); free(r->y10); free(r->m10); free(r->v10); free(r->g10); free(r->gl10); free(r->a10); + free(r->t1); free(r->t10); + memset(r, 0, sizeof *r); +} + +typedef struct { int ok; double m, v, g, gl, a; } origin_t; + +/* same tick walk as est5.c trace_run (one-step and ten-step origins), plus the target tick time */ +static int tr2_run(const c3_ticks *tk, const est4_params *p, tr2_t *tr) +{ + est4_state s; + if (est4_init(p, &s) != EST_OK) return 1; + origin_t ring[C3_TEN]; + memset(ring, 0, sizeof ring); + tr->n1 = tr->n10 = 0; + long first = -1; + for (size_t t = 0; t < tk->n; t++) { + est_pobs ob; + est_obs_class cls = classify(&tk->t[t], &ob); + if (cls == EST_OBS_CLASSES_) return 1; + int ok = cls == EST_OBS_OK; + if (ok && first < 0) first = (long)t; + int scored = first >= 0 && (long)t - first >= (long)C3_BURN_IN; + origin_t *o = &ring[t % C3_TEN]; + if (o->ok) { + o->ok = 0; + if (ok) { + size_t k = tr->n10++; + tr->y10[k] = ob.value; tr->m10[k] = o->m; tr->v10[k] = o->v; tr->g10[k] = o->g; tr->gl10[k] = o->gl; tr->a10[k] = o->a; + tr->t10[k] = tk->t[t].wall_ns; + } + } + if (ok && scored && (uint64_t)s.gap + 1u <= EST_PRED_MAX_H) { + double m, v; + if (est4_moments(&s, 1, &m, &v) != EST_OK) return 1; + size_t k = tr->n1++; + tr->y1[k] = ob.value; tr->m1[k] = m; tr->b1[k] = sqrt(s.g * v); tr->a1[k] = s.anchor; tr->t1[k] = tk->t[t].wall_ns; + } + if (est4_update(&s, ok, ok ? ob.value : NAN) != EST_OK) return 1; + if (ok && scored) { + double m, v; + if (est4_moments(&s, C3_TEN, &m, &v) != EST_OK) return 1; + o->ok = 1; o->m = m; o->v = v; o->g = s.g; o->gl = s.gl; o->a = s.anchor; + } + } + return 0; +} + +/* one grid point = (scale multiplier c on base b, kappa, nu). edges of the symmetric kernel with the upper + * scale (kappa independent) are computed once per (nu, c) and reused for every kappa. */ +static double tp_point(double kappa, double m, double anchor, double y, double lo_u, double hi_u, double lo_l, double hi_l, + double *Flo, double *Fhi) +{ + double a = 1.0 / (1.0 + kappa), b = kappa / (1.0 + kappa); + double kd = nearbyint((y - anchor) / C3_QUANTUM); + if (kd < -(double)EST_PRED_K) kd = -(double)EST_PRED_K; + if (kd > (double)EST_PRED_K) kd = (double)EST_PRED_K; + double mu = m - anchor, xa = (kd - 0.5) * C3_QUANTUM, xb = (kd + 0.5) * C3_QUANTUM; + double Fa = xa < mu ? 2.0 * b * lo_l : b + 2.0 * a * (lo_u - 0.5); + double Fb = xb < mu ? 2.0 * b * hi_l : b + 2.0 * a * (hi_u - 0.5); + if (kd == -(double)EST_PRED_K) Fa = 0.0; + if (kd == (double)EST_PRED_K) Fb = 1.0; + double p = Fb - Fa; if (p < 0) p = 0; + double f = EST_PRED_FLOOR, u = EST_PRED_FLOOR / (double)EST_PRED_N, idx = kd + (double)EST_PRED_K; + if (Flo) *Flo = (1.0 - f) * Fa + u * idx; + if (Fhi) *Fhi = (1.0 - f) * Fb + u * (idx + 1.0); + p = (1.0 - f) * p + u; + return log(p > 1e-300 ? p : 1e-300); +} + +/* symmetric kernel at scale `scale`: returns est4_fast_logp (the exact G1 score) and the un-floored edges */ +static double sym_edges2(double m, double anchor, double y, double scale, double nu, double *lo, double *hi) +{ + est4_pred pr = { 1u, m, scale, nu }; + double Fl, Fh; + double lp = est4_fast_logp(&pr, C3_QUANTUM, anchor, y, &Fl, &Fh); + double kd = nearbyint((y - anchor) / C3_QUANTUM); + if (kd < -(double)EST_PRED_K) kd = -(double)EST_PRED_K; + if (kd > (double)EST_PRED_K) kd = (double)EST_PRED_K; + double f = EST_PRED_FLOOR, u = EST_PRED_FLOOR / (double)EST_PRED_N, idx = kd + (double)EST_PRED_K; + *lo = (Fl - u * idx) / (1.0 - f); + *hi = (Fh - u * (idx + 1.0)) / (1.0 - f); + return lp; +} + +/* log score and floored F interval of one step under (kappa, scale c*b, nu); kappa 1.0 is est4_fast_logp itself */ +static double one_step(double kappa, double m, double anchor, double y, double scale, double nu, double *Flo, double *Fhi) +{ + if (kappa == 1.0) { + est4_pred pr = { 1u, m, scale, nu }; + double fl, fh, lp = est4_fast_logp(&pr, C3_QUANTUM, anchor, y, &fl, &fh); + if (Flo) *Flo = fl; + if (Fhi) *Fhi = fh; + return lp; + } + double lo_u, hi_u, lo_l, hi_l; + sym_edges2(m, anchor, y, scale, nu, &lo_u, &hi_u); + sym_edges2(m, anchor, y, scale * kappa, nu, &lo_l, &hi_l); + return tp_point(kappa, m, anchor, y, lo_u, hi_u, lo_l, hi_l, Flo, Fhi); +} + +typedef struct { double dyn, q, lam, nu, c, kappa; int have; double train; double sum_all; } best1_t; +typedef struct { double phi, nuh, ch, kh; int have; double train; } best2_t; + +/* stage 2 on the steps selected by mask (keep[j] != 0): ten-step mean log score over phi nu_h c_h kappa_h */ +static void stage2(const tr2_t *tr, const int *keep, int kappa_free, best2_t *b) +{ + memset(b, 0, sizeof *b); + size_t m = 0; + for (size_t j = 0; j < tr->n10; j++) m += keep[j] ? 1u : 0u; + if (!m) return; + double best = -INFINITY; + for (int ph = 0; ph < 5; ph++) + for (int u = 0; u < 10; u++) + for (int ci = 0; ci < NCHX; ci++) { + double ch = (double)(10 + 5 * ci) / 100.0, sum[NKS] = { 0 }; + for (size_t j = 0; j < tr->n10; j++) { + if (!keep[j]) continue; + double gb = est4_gbar(tr->g10[j], tr->gl10[j], PHIX[ph], C3_TEN), sc = ch * sqrt(gb * tr->v10[j]); + double lo_u, hi_u; + sum[NKS - 1] += sym_edges2(tr->m10[j], tr->a10[j], tr->y10[j], sc, NUHX[u], &lo_u, &hi_u); + if (kappa_free) + for (int ki = 0; ki < NKS - 1; ki++) { + double lo_l, hi_l; + sym_edges2(tr->m10[j], tr->a10[j], tr->y10[j], sc * KAPPA[ki], NUHX[u], &lo_l, &hi_l); + sum[ki] += tp_point(KAPPA[ki], tr->m10[j], tr->a10[j], tr->y10[j], lo_u, hi_u, lo_l, hi_l, NULL, NULL); + } + } + for (int ki = kappa_free ? 0 : NKS - 1; ki < NKS; ki++) { + double ls = sum[ki] / (double)m; + if (isfinite(ls) && ls > best) { best = ls; b->have = 1; b->phi = PHIX[ph]; b->nuh = NUHX[u]; b->ch = ch; b->kh = KAPPA[ki]; b->train = ls; } + } + } +} + +static double ten_step(const tr2_t *tr, size_t j, const best2_t *b, double *Flo, double *Fhi) +{ + double gb = est4_gbar(tr->g10[j], tr->gl10[j], b->phi, C3_TEN), sc = b->ch * sqrt(gb * tr->v10[j]); + return one_step(b->kh, tr->m10[j], tr->a10[j], tr->y10[j], sc, b->nuh, Flo, Fhi); +} + +static double probit(double u) +{ + if (u < 1e-12) u = 1e-12; + if (u > 1.0 - 1e-12) u = 1.0 - 1e-12; + double lo = -9, hi = 9; + for (int i = 0; i < 80; i++) { double mid = 0.5 * (lo + hi); if (0.5 * erfc(-mid / sqrt(2.0)) < u) lo = mid; else hi = mid; } + return 0.5 * (lo + hi); +} + +/* per-step statistic vector for the screen and the load-stratum analysis */ +#define NV 9 +static const char *VNAME[NV] = { "pit_bin0", "pit_bin9", "lower_miss", "upper_miss", "cov50", "cov80", "cov95", "mean_u_minus_half", "mean_z_mid" }; +static void stepvec(double flo, double fhi, double v[NV]) +{ + step_t st = { 0, flo, fhi, 0 }; + double c[NSTAT]; + contrib(&st, c); + v[0] = c[0]; v[1] = c[9]; v[2] = c[10]; v[3] = c[11]; + v[4] = est_frac_cover(flo, fhi, 0.50); v[5] = est_frac_cover(flo, fhi, 0.80); v[6] = est_frac_cover(flo, fhi, 0.95); + double um = 0.5 * (flo + fhi); + v[7] = um - 0.5; v[8] = probit(um); +} + +typedef struct { size_t n; double *flo, *fhi; int *fold; int64_t *t; } oofset_t; + +typedef struct { double dyn, q, lam, nu, c, kappa; } cfg_t; + +static est4_params cfg_params(const cfg_t *c) +{ + est4_params p = { EST4_G1_LAG, c->dyn, c->q, c->lam, c->nu, c->c, 0.95, 0.8, 0.2, C3_QUANTUM }; + return p; +} + +/* statistics over a set of one-step (or ten-step) F intervals, optionally restricted to a stratum */ +static void accum(double *sum, double *cnt, double flo, double fhi) +{ + double v[NV]; + stepvec(flo, fhi, v); + for (int k = 0; k < NV; k++) sum[k] += v[k]; + *cnt += 1.0; +} + +static void print_stats(const char *tag, const double *sum, double cnt) +{ + printf("%s n %.0f", tag, cnt); + for (int k = 0; k < NV; k++) printf(" %s %.4f", VNAME[k], cnt > 0 ? sum[k] / cnt : NAN); + printf("\n"); +} + +/* gates of v6 section 6 on pooled OOF statistics: outer band and the section 5 inner band (shrunk) */ +static void screen_line(const char *name, double v, double lo, double hi, double shrink) +{ + int outer = v >= lo && v <= hi, inner = v >= lo + shrink && v <= hi - shrink; + printf("gate %s value %.4f outer [%.3f,%.3f] %s inner [%.3f,%.3f] %s\n", name, v, lo, hi, outer ? "PASS" : "FAIL", lo + shrink, hi - shrink, inner ? "PASS" : "FAIL"); +} + +static int cmd_g1sfull(int argc, char **argv) +{ + const char *raw = NULL, *mkp = NULL; + int nfold = 5, stride = 1, boot = 2000; + for (int i = 0; i < argc; i++) { + if (!strcmp(argv[i], "--raw") && i + 1 < argc) raw = argv[++i]; + else if (!strcmp(argv[i], "--marks") && i + 1 < argc) mkp = argv[++i]; + else if (!strcmp(argv[i], "--folds") && i + 1 < argc) nfold = atoi(argv[++i]); + else if (!strcmp(argv[i], "--grid-stride") && i + 1 < argc) stride = atoi(argv[++i]); + else if (!strcmp(argv[i], "--boot") && i + 1 < argc) boot = atoi(argv[++i]); + else { fprintf(stderr, "usage: est6dev g1sfull --raw R --marks M [--folds K] [--grid-stride S] [--boot B]\n"); return 2; } + } + if (!raw || !mkp || nfold < 2 || nfold > 10 || stride < 1 || boot < 100) { fprintf(stderr, "est6dev g1sfull: missing or bad argument\n"); return 2; } + if (forbidden_path(raw) || forbidden_path(mkp)) { fprintf(stderr, "refuse: a held-out path (v5 D2 and every held-out tag are forbidden in v6 development)\n"); return 2; } + char err[512]; + est_file f; + if (est_file_load(raw, &f, err, sizeof err)) { fprintf(stderr, "refuse: %s\n", err); return 1; } + if (!strcmp(f.sha_hex, D2_RAW_SHA)) { fprintf(stderr, "refuse: input is the v5 D2 raw data (SHA-256)\n"); est_file_free(&f); return 2; } + static c3_marks mk; + if (c3_marks_load(mkp, 1, &mk, err, sizeof err)) { fprintf(stderr, "refuse: marks: %s\n", err); est_file_free(&f); return 1; } + if (!strcmp(mk.sha, D2_MARKS_SHA)) { fprintf(stderr, "refuse: marks are the v5 D2 marks (SHA-256)\n"); est_file_free(&f); return 2; } + c3_ticks tk; + if (c3_ticks_build(&f, &tk, err, sizeof err)) { fprintf(stderr, "ticks: %s\n", err); est_file_free(&f); return 1; } + printf("input raw_sha256 %s marks_sha256 %s\n", f.sha_hex, mk.sha); + printf("label DEVELOPMENT RESULT (v5 D1 only; not a held-out result; v6 NOT FROZEN)\n"); + + tr2_t tr; + if (tr2_alloc(&tr, tk.n)) return 1; + size_t nb_max = 2 * mk.n + 2; + int *rank = XMALLOC(nb_max * sizeof *rank), *seen = XCALLOC(nb_max, sizeof *seen); + int *fold1 = NULL; + size_t n1 = 0; + double bestf[10][2]; /* unused placeholder keeps layout simple */ + (void)bestf; + best1_t bfree[10], bctl[10], ball_free, ball_ctl; /* per fold, then whole pool */ + memset(bfree, 0, sizeof bfree); memset(bctl, 0, sizeof bctl); memset(&ball_free, 0, sizeof ball_free); memset(&ball_ctl, 0, sizeof ball_ctl); + for (int i = 0; i < 10; i++) bfree[i].train = bctl[i].train = -INFINITY; + ball_free.train = ball_ctl.train = -INFINITY; + size_t points = 0, skipped = 0; + double *edlo = NULL, *edhi = NULL; + + for (int a = 0; a < NDYN; a += stride) + for (int bq = 0; bq < NQX; bq += stride) + for (int l = 0; l < NLAMX; l += stride) { + est4_params p = { EST4_G1_LAG, DYNX[a], pow(10.0, 2.0 + 0.5 * (double)bq), LAMX[l], 1.0, 1.0, 0.95, 0.8, 0.2, C3_QUANTUM }; + if (tr2_run(&tk, &p, &tr)) { skipped++; continue; } + if (!fold1) { + n1 = tr.n1; + fold1 = XMALLOC(n1 * sizeof *fold1); + edlo = XMALLOC(n1 * sizeof *edlo); edhi = XMALLOC(n1 * sizeof *edhi); + size_t *blk = XMALLOC(n1 * sizeof *blk); + for (size_t i = 0; i < n1; i++) { blk[i] = block_of(&mk, tr.t1[i]); seen[blk[i]] = 1; } + int nr = 0; + for (size_t bb = 0; bb < nb_max; bb++) rank[bb] = seen[bb] ? nr++ : -1; + for (size_t i = 0; i < n1; i++) fold1[i] = rank[blk[i]] % nfold; + free(blk); + } else if (tr.n1 != n1) { fprintf(stderr, "step set changed between grid points\n"); return 1; } + for (int u = 0; u < NNU; u += stride) + for (int ci = 0; ci < NCX; ci += stride) { + double c = (double)(20 + 5 * ci) / 100.0; + double sf[NKS][10], tot[NKS]; + memset(sf, 0, sizeof sf); + for (size_t i = 0; i < n1; i++) { + double lo_u, hi_u, lo_l, hi_l; + sf[NKS - 1][fold1[i]] += sym_edges2(tr.m1[i], tr.a1[i], tr.y1[i], c * tr.b1[i], NUX[u], &lo_u, &hi_u); + for (int ki = 0; ki < NKS - 1; ki++) { + sym_edges2(tr.m1[i], tr.a1[i], tr.y1[i], c * KAPPA[ki] * tr.b1[i], NUX[u], &lo_l, &hi_l); + sf[ki][fold1[i]] += tp_point(KAPPA[ki], tr.m1[i], tr.a1[i], tr.y1[i], lo_u, hi_u, lo_l, hi_l, NULL, NULL); + } + } + points++; + for (int ki = 0; ki < NKS; ki++) { + tot[ki] = 0; + for (int fo = 0; fo < nfold; fo++) tot[ki] += sf[ki][fo]; + cfg_t cf = { DYNX[a], p.q, LAMX[l], NUX[u], c, KAPPA[ki] }; + for (int fo = 0; fo < nfold; fo++) { + double tr_ls = (tot[ki] - sf[ki][fo]); + best1_t *bb = ki == NKS - 1 ? &bctl[fo] : NULL; + if (bb && isfinite(tr_ls) && tr_ls > bb->train) { *bb = (best1_t){ cf.dyn, cf.q, cf.lam, cf.nu, cf.c, cf.kappa, 1, tr_ls, sf[ki][fo] }; } + if (isfinite(tr_ls) && tr_ls > bfree[fo].train) bfree[fo] = (best1_t){ cf.dyn, cf.q, cf.lam, cf.nu, cf.c, cf.kappa, 1, tr_ls, sf[ki][fo] }; + } + if (isfinite(tot[ki]) && tot[ki] > ball_free.train) ball_free = (best1_t){ cf.dyn, cf.q, cf.lam, cf.nu, cf.c, cf.kappa, 1, tot[ki], tot[ki] }; + if (ki == NKS - 1 && isfinite(tot[ki]) && tot[ki] > ball_ctl.train) ball_ctl = (best1_t){ cf.dyn, cf.q, cf.lam, cf.nu, cf.c, cf.kappa, 1, tot[ki], tot[ki] }; + } + } + } + if (!fold1) { fprintf(stderr, "no grid point ran\n"); return 1; } + printf("grid dyn %d q %d lam %d nu %d c %d kappa %d stride %d points %zu filter_failed %zu steps %zu folds %d\n", NDYN, NQX, NLAMX, NNU, NCX, NKS, stride, points, skipped, n1, nfold); + (void)edlo; (void)edhi; + + /* out-of-fold predictions for the chosen configuration of each fold: one-step and ten-step */ + oofset_t oo[2]; /* 0 = G1S free kappa, 1 = control kappa 1.0 */ + size_t n10 = 0; + double *flo10[2] = { NULL, NULL }, *fhi10[2] = { NULL, NULL }, *lp10[2] = { NULL, NULL }; + int64_t *t10 = NULL; int *fold10v = NULL; + for (int w = 0; w < 2; w++) { + oo[w].n = n1; oo[w].flo = XCALLOC(n1, sizeof(double)); oo[w].fhi = XCALLOC(n1, sizeof(double)); oo[w].fold = fold1; oo[w].t = NULL; + } + double *lp1o[2] = { XCALLOC(n1, sizeof(double)), XCALLOC(n1, sizeof(double)) }; + int *step_ok1 = XCALLOC(n1, sizeof(int)); + (void)step_ok1; + char tags[2][8] = { "G1S", "G1ctl" }; + for (int w = 0; w < 2; w++) { + printf("== %s selection by %d-fold block CV, then stage 2 (ten-step) per fold\n", w ? "control kappa=1.0 (G1 exactly)" : "G1S kappa free in {0.6..1.0}", nfold); + for (int fo = 0; fo < nfold; fo++) { + best1_t *b = w ? &bctl[fo] : &bfree[fo]; + cfg_t cf = { b->dyn, b->q, b->lam, b->nu, b->c, b->kappa }; + est4_params p = cfg_params(&cf); + if (tr2_run(&tk, &p, &tr) || tr.n1 != n1) { fprintf(stderr, "refit trace failed\n"); return 1; } + size_t nf = 0; double s = 0; + for (size_t i = 0; i < n1; i++) if (fold1[i] == fo) { + double fl, fh, lp = one_step(cf.kappa, tr.m1[i], tr.a1[i], tr.y1[i], cf.c * tr.b1[i], cf.nu, &fl, &fh); + oo[w].flo[i] = fl; oo[w].fhi[i] = fh; lp1o[w][i] = lp; s += lp; nf++; + } + if (!fold10v) { + n10 = tr.n10; fold10v = XMALLOC(n10 * sizeof *fold10v); t10 = XMALLOC(n10 * sizeof *t10); + for (size_t j = 0; j < n10; j++) { fold10v[j] = rank[block_of(&mk, tr.t10[j])] % nfold; t10[j] = tr.t10[j]; } + for (int ww = 0; ww < 2; ww++) { flo10[ww] = XCALLOC(n10, sizeof(double)); fhi10[ww] = XCALLOC(n10, sizeof(double)); lp10[ww] = XCALLOC(n10, sizeof(double)); } + } + int *keep = XMALLOC(tr.n10 * sizeof *keep); + for (size_t j = 0; j < tr.n10; j++) keep[j] = fold10v[j] != fo; + best2_t b2; + stage2(&tr, keep, !w, &b2); + if (!b2.have) { fprintf(stderr, "est6dev: stage 2 found no finite score (fold %d)\n", fo); return 1; } + for (size_t j = 0; j < tr.n10; j++) if (fold10v[j] == fo) lp10[w][j] = ten_step(&tr, j, &b2, &flo10[w][j], &fhi10[w][j]); + free(keep); + printf("fold %d steps %zu stage1 dyn %g q %g lam %g nu %g c %.2f kappa %.1f train_mean_logscore %.6f oof_mean_logscore %.6f | stage2 phi %g nu_h %g c_h %.2f kappa_h %.1f\n", + fo, nf, cf.dyn, cf.q, cf.lam, cf.nu, cf.c, cf.kappa, b->train / (double)(n1 - nf), nf ? s / (double)nf : 0.0, b2.phi, b2.nuh, b2.ch, b2.kh); + } + /* pooled OOF statistics and the screen */ + double sum[NV] = { 0 }, cnt = 0, lsum = 0; + for (size_t i = 0; i < n1; i++) { accum(sum, &cnt, oo[w].flo[i], oo[w].fhi[i]); lsum += lp1o[w][i]; } + printf("oof_pooled %s mean_logscore %.6f\n", tags[w], lsum / (double)n1); + print_stats("oof_pooled", sum, cnt); + double ten_cov = 0, ten_ls = 0; + for (size_t j = 0; j < n10; j++) { ten_cov += est_frac_cover(flo10[w][j], fhi10[w][j], 0.95); ten_ls += lp10[w][j]; } + printf("oof_pooled_ten_step %s n %zu coverage95 %.4f mean_logscore %.6f\n", tags[w], n10, ten_cov / (double)n10, ten_ls / (double)n10); + { /* bins */ + double bins[10] = { 0 }; + for (size_t i = 0; i < n1; i++) { step_t st = { 0, oo[w].flo[i], oo[w].fhi[i], 0 }; double c[NSTAT]; contrib(&st, c); for (int j = 0; j < 10; j++) bins[j] += c[j]; } + printf("oof_bins %s", tags[w]); + for (int j = 0; j < 10; j++) printf(" %.4f", bins[j] / (double)n1); + printf("\n"); + double lag = 0, zz = 0, zm = 0; size_t ln = 0; + double zprev = NAN; + for (size_t i = 0; i < n1; i++) { + double z = probit(0.5 * (oo[w].flo[i] + oo[w].fhi[i])); + zz += z * z; zm += z; + if (i > 0 && tr.t1[i] - tr.t1[i - 1] > 500000000LL && tr.t1[i] - tr.t1[i - 1] < 1500000000LL) { lag += z * zprev; ln++; } + zprev = z; + } + double zbar = zm / (double)n1, var = zz / (double)n1 - zbar * zbar; + (void)var; + printf("oof_lag1_z_uncentred %s %.4f over %zu consecutive pairs\n", tags[w], ln ? lag / (double)ln : NAN, ln); + screen_line("P1 cov50", sum[4] / cnt, 0.46, 0.54, 0.01); + screen_line("P2 cov80", sum[5] / cnt, 0.76, 0.84, 0.01); + screen_line("P3 cov95", sum[6] / cnt, 0.93, 0.97, 0.02); + screen_line("P4 lower_miss", sum[2] / cnt, 0.010, 0.040, 0.01); + screen_line("P5 upper_miss", sum[3] / cnt, 0.010, 0.040, 0.01); + for (int j = 0; j < 10; j++) { char nm[16]; snprintf(nm, sizeof nm, "P6 bin%d", j); screen_line(nm, bins[j] / (double)n1, 0.07, 0.13, 0.01); } + screen_line("P7 ten_cov95", ten_cov / (double)n10, 0.90, 0.99, 0.03); + } + /* load-stratum analysis of the OOF PIT with block bootstrap within stratum */ + { + size_t nb = nb_max; + double (*bs)[NV] = XCALLOC(nb, sizeof *bs); double *bn = XCALLOC(nb, sizeof *bn); + for (size_t i = 0; i < n1; i++) { size_t b = block_of(&mk, tr.t1[i]); accum(bs[b], &bn[b], oo[w].flo[i], oo[w].fhi[i]); } + const int lvv[4] = { 0, 6, 12, 18 }; + for (int li = 0; li < 4; li++) { + size_t *ids = XMALLOC(nb * sizeof *ids); size_t ni = 0; + double tot[NV] = { 0 }, tn = 0; + for (size_t b = 0; b < nb; b++) { + if (bn[b] <= 0) continue; + int lv = (b & 1u) ? mk.level[b / 2] : 0; + if (lv != lvv[li]) continue; + ids[ni++] = b; tn += bn[b]; + for (int k = 0; k < NV; k++) tot[k] += bs[b][k]; + } + if (ni == 0) { free(ids); continue; } + uint64_t rng = 0xE6B007ull + (uint64_t)li; + double *dr = XMALLOC((size_t)boot * NV * sizeof *dr); + for (int r = 0; r < boot; r++) { + double ss[NV] = { 0 }, nn = 0; + for (size_t k = 0; k < ni; k++) { size_t b = ids[splitmix64(&rng) % ni]; nn += bn[b]; for (int q = 0; q < NV; q++) ss[q] += bs[b][q]; } + for (int q = 0; q < NV; q++) dr[(size_t)r * NV + q] = ss[q] / nn; + } + printf("stratum %s L%d blocks %zu steps %.0f", tags[w], lvv[li], ni, tn); + for (int k = 0; k < NV; k++) { + if (k == 4 || k == 5) continue; + double mean = 0, var = 0; + for (int r = 0; r < boot; r++) mean += dr[(size_t)r * NV + k]; + mean /= boot; + for (int r = 0; r < boot; r++) { double d = dr[(size_t)r * NV + k] - mean; var += d * d; } + var /= (boot - 1); + printf(" %s %.4f(se %.4f)", VNAME[k], tot[k] / tn, sqrt(var)); + } + printf("\n"); + free(dr); free(ids); + } + free(bs); free(bn); + } + } + /* final refit on the whole pool (committed params would come from this) */ + printf("== final whole-pool refit (stage 1; same grid)\n"); + printf("final G1S dyn %g q %g lam %g nu %g c %.2f kappa %.1f in_sample_mean_logscore %.6f\n", ball_free.dyn, ball_free.q, ball_free.lam, ball_free.nu, ball_free.c, ball_free.kappa, ball_free.train / (double)n1); + printf("final control dyn %g q %g lam %g nu %g c %.2f kappa %.1f in_sample_mean_logscore %.6f\n", ball_ctl.dyn, ball_ctl.q, ball_ctl.lam, ball_ctl.nu, ball_ctl.c, ball_ctl.kappa, ball_ctl.train / (double)n1); + printf("tie_rule G1S preferred over G1 only if out-of-fold log score exceeds the control by more than 0.01 nats\n"); + c3_ticks_free(&tk); est_file_free(&f); tr2_free(&tr); + return 0; +} + + +/* two-piece predictive self check on synthetic inputs (no data file): for each kappa, nu, scale and location + * the bin probabilities over k = -K..K sum to 1, the floored CDF is continuous and non-decreasing across bins, + * and kappa = 1.0 is exactly est4_fast_logp. The two-piece formula at kappa = 1.0 agrees with it to rounding. */ +static int cmd_twopiece_selfcheck(void) +{ + static const double nus[3] = { 0.8, 1.25, 5.0 }, scs[3] = { 0.3, 1.0, 4.0 }, locs[3] = { 0.0, 0.37, -2.6 }; + double maxsum = 0, maxjump = 0, maxk1 = 0; int bad = 0; + for (int ki = 0; ki < NKS; ki++) + for (int a = 0; a < 3; a++) for (int b = 0; b < 3; b++) for (int c = 0; c < 3; c++) { + double anchor = 1234.0 * C3_QUANTUM, m = anchor + locs[c] * C3_QUANTUM, sum = 0, prev_hi = 0; + for (int k = -EST_PRED_K; k <= EST_PRED_K; k++) { + double y = anchor + (double)k * C3_QUANTUM, fl, fh; + double lp = one_step(KAPPA[ki], m, anchor, y, scs[b] * C3_QUANTUM, nus[a], &fl, &fh); + sum += exp(lp); + if (k > -EST_PRED_K) { double j = fabs(fl - prev_hi); if (j > maxjump) maxjump = j; } + if (fh < fl - 1e-15) bad = 1; + prev_hi = fh; + if (KAPPA[ki] == 1.0 && k >= -3 && k <= 3) { + double lo_u, hi_u, lp2, f2l, f2h; + sym_edges2(m, anchor, y, scs[b] * C3_QUANTUM, nus[a], &lo_u, &hi_u); + lp2 = tp_point(1.0, m, anchor, y, lo_u, hi_u, lo_u, hi_u, &f2l, &f2h); + double d = fabs(lp2 - lp); if (d > maxk1) maxk1 = d; + } + } + if (fabs(sum - 1.0) > maxsum) maxsum = fabs(sum - 1.0); + } + printf("twopiece max_abs(sum p - 1) %.3g max_cdf_jump_between_bins %.3g max_abs(two_piece_formula_at_kappa1 - est4_fast_logp) %.3g monotone %s\n", maxsum, maxjump, maxk1, bad ? "NO" : "yes"); + printf("twopiece-selfcheck: %s\n", (maxsum < 1e-9 && maxjump < 1e-9 && maxk1 < 1e-9 && !bad) ? "PASS" : "FAIL"); + return (maxsum < 1e-9 && maxjump < 1e-9 && maxk1 < 1e-9 && !bad) ? 0 : 1; +} + int main(int argc, char **argv) { - if (argc < 2) { fprintf(stderr, "usage: est6dev g1pit|g1s|sched|pick|plan6 ...\n"); return 2; } + if (argc < 2) { fprintf(stderr, "usage: est6dev g1pit|g1s|g1sfull|twopiece-selfcheck|sched|pick|plan6 ...\n"); return 2; } if (!strcmp(argv[1], "g1pit")) return cmd_g1pit(argc - 2, argv + 2); if (!strcmp(argv[1], "sched")) return cmd_sched(argc - 2, argv + 2); if (!strcmp(argv[1], "pick")) return cmd_pick(argc - 2, argv + 2); if (!strcmp(argv[1], "plan6")) return cmd_plan6(argc - 2, argv + 2); if (!strcmp(argv[1], "g1s")) return cmd_g1s(argc - 2, argv + 2); - fprintf(stderr, "usage: est6dev g1pit|g1s|sched|pick|plan6 ...\n"); + if (!strcmp(argv[1], "g1sfull")) return cmd_g1sfull(argc - 2, argv + 2); + if (!strcmp(argv[1], "twopiece-selfcheck")) return cmd_twopiece_selfcheck(); + fprintf(stderr, "usage: est6dev g1pit|g1s|g1sfull|twopiece-selfcheck|sched|pick|plan6 ...\n"); return 2; } diff --git a/tools/estimation/est6opchar.c b/tools/estimation/est6opchar.c index db8ff5e09..da756d384 100644 --- a/tools/estimation/est6opchar.c +++ b/tools/estimation/est6opchar.c @@ -3,7 +3,7 @@ * data file at all, so no held-out file can be touched. It simulates the pooled H1 + H2 scoring of the * primary gates P1 to P10 and the three-way verdict on synthetic PIT sequences. * - * est6opchar run --case a|b|c [--bin0 X] [--reps N] [--boot B] [--runs R] [--seconds S] + * est6opchar run --case a|b|c|d [--bin0 X] [--reps N] [--boot B] [--runs R] [--seconds S] * [--w W] [--rho RHO] [--rho10 RHO10] [--seed SEED] * est6opchar deff [--reps N] [--runs R] [--w W] [--rho RHO] [--seed SEED] * est6opchar selftest @@ -93,6 +93,36 @@ static double cells_inv(double p) } return 1.0; } +/* case d: regime-dependent PIT. Per declared load level (idle, L6, L12, L18) a piecewise-uniform PIT built from the + * measured v5 D1 per-level G1 shares (appendix section 2: bin 0, bin 9, lower miss, upper miss); bins 1 to 8 share the + * remaining mass equally (an ASSUMPTION: per-level middle bins were not tabulated). */ +static const double LV_BIN0[4] = { 0.116, 0.111, 0.025, 0.000 }, LV_BIN9[4] = { 0.077, 0.114, 0.159, 0.184 }; +static const double LV_LOW[4] = { 0.030, 0.010, 0.000, 0.000 }, LV_UP[4] = { 0.036, 0.017, 0.041, 0.085 }; +static double lv_cum[4][NCELL + 1]; +static void make_level_cells(void) +{ + for (int l = 0; l < 4; l++) { + double m[NCELL], mid = (1.0 - LV_BIN0[l] - LV_BIN9[l]) / 8.0; + m[0] = LV_LOW[l]; m[1] = LV_BIN0[l] - LV_LOW[l]; + for (int j = 1; j < 9; j++) m[j + 1] = mid; + m[10] = LV_BIN9[l] - LV_UP[l]; m[11] = LV_UP[l]; + double cum = 0; + for (int i = 0; i <= NCELL; i++) { lv_cum[l][i] = cum; if (i < NCELL) cum += m[i]; } + lv_cum[l][NCELL] = 1.0; + } +} +static double level_inv(int l, double p) +{ + static const double cut[NCELL + 1] = { 0, 0.025, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.975, 1.0 }; + for (int i = 0; i < NCELL; i++) { + double w = lv_cum[l][i + 1] - lv_cum[l][i]; + if ((p <= lv_cum[l][i + 1] && w > 0) || i == NCELL - 1) { + double f = w > 0 ? (p - lv_cum[l][i]) / w : 0.5; + return cut[i] + f * (cut[i + 1] - cut[i]); + } + } + return 1.0; +} /* scale s so that P(|s z| < 1.959964) = cov */ static double scale_for_cov(double cov) { @@ -136,6 +166,8 @@ static void gen_seq(const cfg_t *g, u64 *rng, int kind, seq_t *sq) if (step >= 30 && n < MAXN) { double u, zz; if (g->cas == 1) { double s = kind ? g->s_b10 : g->s_b; zz = s * z0; u = Phi(zz); } + else if (g->cas == 3 && kind == 0) { u = level_inv(lv, Phi(z0)); zz = probit(u < 1e-12 ? 1e-12 : u > 1 - 1e-12 ? 1 - 1e-12 : u); } + else if (g->cas == 3) { zz = g->s_c10 * z0; u = Phi(zz); } else if (g->cas == 2 && kind == 0) { u = cells_inv(Phi(z0)); zz = probit(u < 1e-12 ? 1e-12 : u > 1 - 1e-12 ? 1 - 1e-12 : u); } else if (g->cas == 2) { zz = g->s_c10 * z0; u = Phi(zz); } else { zz = z0; u = Phi(z0); } @@ -251,16 +283,17 @@ static int cmd_run(int argc, char **argv) else if (!strcmp(argv[i], "--seed") && i + 1 < argc) seed = strtoull(argv[++i], NULL, 0); else { fprintf(stderr, "est6opchar run: bad argument %s\n", argv[i]); return 2; } } - if (cs != 'a' && cs != 'b' && cs != 'c') { fprintf(stderr, "case must be a, b or c\n"); return 2; } + if (cs != 'a' && cs != 'b' && cs != 'c' && cs != 'd') { fprintf(stderr, "case must be a, b, c or d\n"); return 2; } if (g.nrun < 1 || g.nrun > 4 || g.seconds < 100 || g.seconds > 4000 || reps < 1 || boot < 200 || g.w < 0 || g.w >= 1 || g.rho < 0 || g.rho >= 1 || g.rho10 < 0 || g.rho10 >= 1) { fprintf(stderr, "bad parameter range\n"); return 2; } - g.cas = cs == 'a' ? 0 : cs == 'b' ? 1 : 2; + g.cas = cs == 'a' ? 0 : cs == 'b' ? 1 : cs == 'c' ? 2 : 3; setup(&g); make_cells(g.bin0); + make_level_cells(); u64 rng = seed; int cnt[3] = { 0, 0, 0 }; for (int r = 0; r < reps; r++) cnt[one_rep(&g, &rng, boot)]++; printf("case %c bin0 %.4f runs %d seconds %ld w %.3f rho %.3f rho10 %.3f reps %d boot %d seed 0x%llx\n", cs, g.bin0, g.nrun, g.seconds, g.w, g.rho, g.rho10, reps, boot, seed); - printf("PASS %.4f NOT_ESTABLISHED %.4f HELD_OUT_FAIL %.4f (counts %d %d %d)\n", (double)cnt[0] / reps, (double)cnt[1] / reps, (double)cnt[2] / reps, cnt[0], cnt[1], cnt[2]); + printf("PASS %.4f NOT_ESTABLISHED %.4f HELD_OUT_FAIL %.4f (counts %d %d %d; Monte Carlo SE at most %.4f)\n", (double)cnt[0] / reps, (double)cnt[1] / reps, (double)cnt[2] / reps, cnt[0], cnt[1], cnt[2], 0.5 / sqrt((double)reps)); return 0; } diff --git a/tools/estimation/est6opchar_table2.sh b/tools/estimation/est6opchar_table2.sh new file mode 100755 index 000000000..f23722818 --- /dev/null +++ b/tools/estimation/est6opchar_table2.sh @@ -0,0 +1,16 @@ +#!/bin/sh +# SIMULATION table 2 for est-v6 section 6 (appendix est-v6-appendix-prefreeze.md section 5b). Reads no data file. +# usage: est6opchar_table2.sh [reps] +# Adds to table 1: (d) a forecaster with the measured regime-dependent PIT (case d), a replication of (a) and (b) +# under another seed, and the false-accept rate (PASS) of forecasters whose true bin 0 breaks the 0.07 limit, +# with three runs for comparison. All rows: rho 0.02, boot 1000. +set -eu +B=${1:?usage: est6opchar_table2.sh BIN [reps]} +R=${2:-20000} +row() { "$B" run "$@" --rho 0.02 --reps "$R" --boot 1000 | tail -n 2 | paste -sd' '; } +echo "# (d) regime-dependent PIT (v5 D1 per-level shares), runs 2 and 3" +for w in 0.08 0.12; do for runs in 2 3; do row --case d --w $w --runs $runs; done; done +echo "# replication of (a) and (b) under seed 0xE6A777 (table 1 used 0xE6A001)" +for c in a b; do for runs in 2 3; do row --case $c --w 0.08 --runs $runs --seed 0xE6A777; done; done +echo "# false accept: true bin 0 below the 0.07 limit, runs 2 and 3, w 0.08" +for b0 in 0.070 0.068 0.065 0.060 0.055; do for runs in 2 3; do row --case c --bin0 $b0 --w 0.08 --runs $runs; done; done diff --git a/tools/estimation/test_est6dev.sh b/tools/estimation/test_est6dev.sh index 0c8714c53..7721ccc09 100755 --- a/tools/estimation/test_est6dev.sh +++ b/tools/estimation/test_est6dev.sh @@ -85,4 +85,25 @@ out2=$("$E" g1pit --raw $D1/machine-state.ndjson --marks $D1/machine-state-marks a=$("$O" run --case a --reps 50 --boot 300) ; b=$("$O" run --case a --reps 50 --boot 300) [ "$a" = "$b" ] && chk ok x || chk bad "est6opchar not deterministic" + +# 4b. full G1S: two-piece predictive self check, held-out refusals, determinism, label, control is kappa 1.0 +"$E" twopiece-selfcheck | grep -q '^twopiece-selfcheck: PASS$' && chk ok x || chk bad "two-piece self check" +for p in evidence/EST5/raw/20261005T112838Z-est5-heldout-silicon evidence/X/raw/zz-est6-heldout-silicon; do + rc=0 + "$E" g1sfull --raw "$p/machine-state.ndjson" --marks "$p/machine-state-marks.txt" >/dev/null 2>&1 || rc=$? + [ "$rc" = 2 ] && chk ok x || chk bad "g1sfull did not refuse held-out path $p (rc $rc)" +done +G1=${TMPDIR:-/tmp}/e6dev.g1sfull.$$ +"$E" g1sfull --raw $D1/machine-state.ndjson --marks $D1/machine-state-marks.txt --grid-stride 6 --boot 200 > $G1.a +"$E" g1sfull --raw $D1/machine-state.ndjson --marks $D1/machine-state-marks.txt --grid-stride 6 --boot 200 > $G1.b +cmp -s $G1.a $G1.b && chk ok x || chk bad "g1sfull not deterministic" +grep -q '^label DEVELOPMENT RESULT' $G1.a && chk ok x || chk bad "g1sfull development label" +grep -q '^grid .* steps 2652 folds 5$' $G1.a && chk ok x || chk bad "g1sfull step count 2652 (same steps as g1pit)" +grep -q '^final control .* kappa 1.0 ' $G1.a && chk ok x || chk bad "g1sfull control kappa" +rm -f $G1.a $G1.b + +# 5b. opchar case d (regime-dependent PIT) deterministic +a=$("$O" run --case d --reps 50 --boot 300) ; b=$("$O" run --case d --reps 50 --boot 300) +[ "$a" = "$b" ] && chk ok x || chk bad "est6opchar case d not deterministic" + if [ "$fail" = 0 ]; then echo "test-est6dev: PASS ($n checks)"; else exit 1; fi