Voynich Complete Reproducibility Compendium - 2026-08-28 Page 3493 row = {"config": name, "seed": seed, "k": k, "n_groups": n_groups, "restarts": restarts, "m": 22, "glyphs_real": sum(len(w) for ln in clines for w in ln), "glyphs_surrogate": sum(len(w) for ln in surrogate for w in ln), "identical_lines": sum(a == b for a, b in zip(clines, surrogate))} for stream_name, lines in (("real", clines), ("surrogate", surrogate)): _segmap, ustream, maps = pipeline_classes(lines, k, [22]) cm = maps[22] for lang in LANGS: lm, anchor = _STATE["lms"][lang] r = match_index(ustream, cm, 22, lm, anchor, restarts=restarts, seed=seed) row[f"{stream_name}_{lang}"] = { "index": r["index"], "test_bits": r["test_bits"], "scrambled_bits": r["scrambled_bits"], "anchor_bits": r["anchor_bits"], } for lang in LANGS: row[f"differential_{lang}"] = (row[f"real_{lang}"]["index"] - row[f"surrogate_{lang}"]["index"]) row["seconds"] = time.time() - t0 return row def parse_seeds(text: str) -> list[int]: out = [] for part in text.split(","): if "-" in part: a, b = part.split("-") out.extend(range(int(a), int(b) + 1)) else: out.append(int(part)) return out def summarise(rows: list[dict]) -> dict: summary = {} for name in CONFIG_ORDER: sub = [r for r in rows if r["config"] == name] if not sub: continue entry = {"n_seeds": len(sub), "seeds": sorted(r["seed"] for r in sub)} for lang in LANGS: d = [r[f"differential_{lang}"] for r in sub] real = [r[f"real_{lang}"]["index"] for r in sub] sur = [r[f"surrogate_{lang}"]["index"] for r in sub] entry[lang] = { "differential_mean": sum(d) / len(d), "differential_min": min(d), "differential_max": max(d), "real_mean": sum(real) / len(real), "surrogate_mean": sum(sur) / len(sur), } summary[name] = entry return summary def main() -> None: ap = argparse.ArgumentParser() ap.add_argument("--seeds", default="0-4") ap.add_argument("--configs", default=",".join(CONFIG_ORDER)) ap.add_argument("--restarts", type=int, default=8) ap.add_argument("--workers", type=int, default=5) ap.add_argument("--output", type=Path, default=OUT / "differentials.json") args = ap.parse_args() seeds = parse_seeds(args.seeds) configs = [c for c in CONFIG_ORDER if c in args.configs.split(",")] # priority: main configs over all seeds first, then the two variants tasks = [(c, s, args.restarts) for c in configs if c in ("H3", "H2", "H5") for s in seeds] tasks += [(c, s, args.restarts) for c in configs if c in ("H3mix", "H3rot") for s in seeds] print(f"{len(tasks)} tasks, {args.workers} workers", flush=True) rows: list[dict] = [] started = time.time() def flush(): args.output.parent.mkdir(exist_ok=True) payload = { "description": "index(real synthetic cipher) - index(order-3 surrogate) " "per config and seed; m=22 classes; latin_holdout = right " "language, german = wrong language", "cipher_seed": f"random.Random({CIPHER_SEED_BASE} + seed) per config", "surrogate_seed": f"attack_voynich.ngram_generate(seed={SURROGATE_SEED_BASE} + seed)", "attack_seed": "seed", "restarts": args.restarts, "elapsed_seconds": time.time() - started, "summary": summarise(rows), "runs": sorted(rows, key=lambda r: (CONFIG_ORDER.index(r["config"]), r["seed"])), } args.output.write_text(json.dumps(payload, indent=2, default=float) + "\n") def report(row): rows.append(row) print(f"{row['config']:6s} seed={row['seed']} " f"latin real={row['real_latin_holdout']['index']:.3f} " f"sur={row['surrogate_latin_holdout']['index']:.3f} " f"diff={row['differential_latin_holdout']:+.3f} | " f"german real={row['real_german']['index']:.3f} " f"sur={row['surrogate_german']['index']:.3f} "