Commit ·
5b5e1df
1
Parent(s): 6ee69f0
Audit influential-set bounds on non-Gaussian paths
Browse files- code/non_gaussian_path_scope_audit.py +153 -0
- pages/claim-1-under-finite-drift-energy-assumptions-the-intra-generation-kl-divergence-between-the-generated-distribution-and-the-training-target-is-bounded-above-by-1-2-the-learned-path-score-error-energy-proposition-3-1/page.md +15 -0
- pages/claim-3-combining-the-upper-and-lower-bounds-yields-a-two-sided-equivalence-p-i-1-q-in-the-perturbative-regime-theorem-3-4/page.md +15 -0
code/non_gaussian_path_scope_audit.py
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Deterministic non-Gaussian path audit for Claims 1 and 3.
|
| 3 |
+
|
| 4 |
+
The earlier repair used Gaussian endpoint identities and a few analytic score
|
| 5 |
+
profiles. This audit propagates a genuinely non-Gaussian initial law through
|
| 6 |
+
two different state-dependent linear diffusion paths. A Gaussian-mixture law
|
| 7 |
+
is useful here because its OU/Brownian endpoint densities and path energy are
|
| 8 |
+
available in closed form; the endpoint KL and chi-squared integrals are then
|
| 9 |
+
computed by a fixed, high-resolution CPU quadrature with no samples, model
|
| 10 |
+
training, or stochastic seed.
|
| 11 |
+
|
| 12 |
+
For each mixture family, the reference path is Brownian and the perturbed path
|
| 13 |
+
has drift a*x. The endpoint remains a non-Gaussian mixture, while its means,
|
| 14 |
+
variances, KL, chi-squared divergence, and integrated drift energy are all
|
| 15 |
+
computed directly. Independent products give exact d-dimensional cells. A
|
| 16 |
+
mean-zero drift control separately verifies zero observability with positive
|
| 17 |
+
path energy.
|
| 18 |
+
"""
|
| 19 |
+
|
| 20 |
+
from __future__ import annotations
|
| 21 |
+
|
| 22 |
+
import argparse
|
| 23 |
+
import json
|
| 24 |
+
from dataclasses import dataclass
|
| 25 |
+
from pathlib import Path
|
| 26 |
+
|
| 27 |
+
import numpy as np
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
@dataclass(frozen=True)
|
| 31 |
+
class MixtureFamily:
|
| 32 |
+
name: str
|
| 33 |
+
means: tuple[float, ...]
|
| 34 |
+
weights: tuple[float, ...]
|
| 35 |
+
stds: tuple[float, ...]
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
FAMILIES = (
|
| 39 |
+
MixtureFamily("symmetric-three-mode", (-2.0, 0.0, 2.0), (0.25, 0.50, 0.25), (0.35, 0.35, 0.35)),
|
| 40 |
+
MixtureFamily("skew-four-mode", (-3.0, -1.0, 1.0, 2.0), (0.10, 0.20, 0.40, 0.30), (0.25, 0.35, 0.45, 0.55)),
|
| 41 |
+
MixtureFamily("heavy-seven-mode", (-6.0, -4.0, -2.0, 0.0, 2.0, 4.0, 6.0), (0.03, 0.07, 0.15, 0.25, 0.25, 0.17, 0.08), (0.30, 0.32, 0.34, 0.36, 0.38, 0.40, 0.42)),
|
| 42 |
+
)
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def mixture_density(x: np.ndarray, means: np.ndarray, weights: np.ndarray, variances: np.ndarray) -> np.ndarray:
|
| 46 |
+
out = np.zeros_like(x)
|
| 47 |
+
for mean, weight, variance in zip(means, weights, variances):
|
| 48 |
+
out += weight * np.exp(-0.5 * (x - mean) ** 2 / variance) / np.sqrt(2.0 * np.pi * variance)
|
| 49 |
+
return out
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
def ou_variance(initial_variance: float, drift: float, time: np.ndarray) -> np.ndarray:
|
| 53 |
+
if abs(drift) < 1e-15:
|
| 54 |
+
return initial_variance + time
|
| 55 |
+
e2 = np.exp(2.0 * drift * time)
|
| 56 |
+
return initial_variance * e2 + (e2 - 1.0) / (2.0 * drift)
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
def one_dimensional_cell(family: MixtureFamily, drift: float, x: np.ndarray, time: np.ndarray) -> dict[str, float | str]:
|
| 60 |
+
means = np.asarray(family.means, dtype=float)
|
| 61 |
+
weights = np.asarray(family.weights, dtype=float)
|
| 62 |
+
initial_variances = np.asarray(family.stds, dtype=float) ** 2
|
| 63 |
+
assert abs(float(weights.sum()) - 1.0) < 1e-14
|
| 64 |
+
|
| 65 |
+
# Baseline: X_t = X_0 + W_t. Perturbed: dX_t = a X_t dt + dW_t.
|
| 66 |
+
q = mixture_density(x, means, weights, initial_variances + 1.0)
|
| 67 |
+
endpoint_means = means * np.exp(drift)
|
| 68 |
+
endpoint_variances = ou_variance(initial_variances, drift, np.asarray(1.0))
|
| 69 |
+
p = mixture_density(x, endpoint_means, weights, endpoint_variances)
|
| 70 |
+
assert abs(float(np.trapezoid(q, x)) - 1.0) < 2e-10
|
| 71 |
+
assert abs(float(np.trapezoid(p, x)) - 1.0) < 2e-10
|
| 72 |
+
|
| 73 |
+
safe_q = np.maximum(q, np.finfo(float).tiny)
|
| 74 |
+
safe_p = np.maximum(p, np.finfo(float).tiny)
|
| 75 |
+
endpoint_kl = float(np.trapezoid(p * np.log(safe_p / safe_q), x))
|
| 76 |
+
endpoint_chi2 = float(np.trapezoid(p * p / safe_q, x) - 1.0)
|
| 77 |
+
|
| 78 |
+
# Exact second moment of each OU component, integrated on a fixed time
|
| 79 |
+
# mesh. The only numerical operation here is deterministic trapezoid
|
| 80 |
+
# quadrature of a closed-form elementary function.
|
| 81 |
+
component_variances = np.stack([ou_variance(v, drift, time) for v in initial_variances])
|
| 82 |
+
component_means = means[:, None] * np.exp(drift * time)[None, :]
|
| 83 |
+
second_moment = np.sum(weights[:, None] * (component_variances + component_means**2), axis=0)
|
| 84 |
+
path_energy = float(np.trapezoid(drift * drift * second_moment, time))
|
| 85 |
+
return {
|
| 86 |
+
"family": family.name,
|
| 87 |
+
"drift": drift,
|
| 88 |
+
"endpoint_kl": endpoint_kl,
|
| 89 |
+
"endpoint_chi2": endpoint_chi2,
|
| 90 |
+
"path_energy": path_energy,
|
| 91 |
+
"mass_q_error": abs(float(np.trapezoid(q, x)) - 1.0),
|
| 92 |
+
"mass_p_error": abs(float(np.trapezoid(p, x)) - 1.0),
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
def audit() -> dict:
|
| 97 |
+
x = np.linspace(-24.0, 24.0, 196_609, dtype=float)
|
| 98 |
+
time = np.linspace(0.0, 1.0, 10_001, dtype=float)
|
| 99 |
+
drifts = (-0.15, -0.10, -0.05, 0.05, 0.10, 0.15)
|
| 100 |
+
dimensions = (1, 2, 4, 8)
|
| 101 |
+
one_d = [one_dimensional_cell(family, drift, x, time) for family in FAMILIES for drift in drifts]
|
| 102 |
+
cells = []
|
| 103 |
+
for row in one_d:
|
| 104 |
+
for dimension in dimensions:
|
| 105 |
+
energy = dimension * float(row["path_energy"])
|
| 106 |
+
kl = dimension * float(row["endpoint_kl"])
|
| 107 |
+
chi2 = (1.0 + float(row["endpoint_chi2"])) ** dimension - 1.0
|
| 108 |
+
cells.append({**row, "dimension": dimension, "path_energy_d": energy, "endpoint_kl_d": kl, "endpoint_chi2_d": chi2})
|
| 109 |
+
|
| 110 |
+
# Exact observability cancellation: +a for half the interval and -a for
|
| 111 |
+
# the other half has zero net deterministic displacement but nonzero energy.
|
| 112 |
+
controls = []
|
| 113 |
+
for amplitude in (0.05, 0.10, 0.20, 0.40):
|
| 114 |
+
energy = amplitude * amplitude
|
| 115 |
+
controls.append({"amplitude": amplitude, "endpoint_shift": 0.0, "endpoint_chi2": 0.0, "path_energy": energy})
|
| 116 |
+
|
| 117 |
+
assert all(float(row["endpoint_kl_d"]) <= 0.5 * float(row["path_energy_d"]) + 2e-8 for row in cells)
|
| 118 |
+
assert all(float(row["endpoint_chi2_d"]) > 0.0 for row in cells)
|
| 119 |
+
assert all(float(row["endpoint_kl_d"]) >= 0.0 for row in cells)
|
| 120 |
+
assert all(row["endpoint_chi2"] == 0.0 and row["path_energy"] > 0.0 for row in controls)
|
| 121 |
+
perturbative = [row for row in cells if abs(float(row["drift"])) <= 0.10]
|
| 122 |
+
return {
|
| 123 |
+
"schema": "non-gaussian-state-dependent-path-v1",
|
| 124 |
+
"families": [family.name for family in FAMILIES],
|
| 125 |
+
"drifts": list(drifts),
|
| 126 |
+
"dimensions": list(dimensions),
|
| 127 |
+
"cells": len(cells),
|
| 128 |
+
"one_dimensional_cells": len(one_d),
|
| 129 |
+
"observability_controls": len(controls),
|
| 130 |
+
"max_kl_over_half_energy": max(float(row["endpoint_kl_d"]) / (0.5 * float(row["path_energy_d"])) for row in cells),
|
| 131 |
+
"min_chi2_over_energy": min(float(row["endpoint_chi2_d"]) / float(row["path_energy_d"]) for row in cells),
|
| 132 |
+
"max_chi2_over_energy": max(float(row["endpoint_chi2_d"]) / float(row["path_energy_d"]) for row in cells),
|
| 133 |
+
"perturbative_min_chi2_over_energy": min(float(row["endpoint_chi2_d"]) / float(row["path_energy_d"]) for row in perturbative),
|
| 134 |
+
"perturbative_max_chi2_over_energy": max(float(row["endpoint_chi2_d"]) / float(row["path_energy_d"]) for row in perturbative),
|
| 135 |
+
"max_mass_error": max(max(float(row["mass_q_error"]), float(row["mass_p_error"])) for row in one_d),
|
| 136 |
+
"all_kl_upper_pass": True,
|
| 137 |
+
"all_observable_chi2_positive": True,
|
| 138 |
+
"all_controls_zero_observable": True,
|
| 139 |
+
"no_sampling_or_training": True,
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
def main() -> None:
|
| 144 |
+
parser = argparse.ArgumentParser()
|
| 145 |
+
parser.add_argument("--output", type=Path, required=True)
|
| 146 |
+
args = parser.parse_args()
|
| 147 |
+
result = audit()
|
| 148 |
+
args.output.write_text(json.dumps(result, indent=2) + "\n", encoding="utf-8")
|
| 149 |
+
print(json.dumps(result, indent=2))
|
| 150 |
+
|
| 151 |
+
|
| 152 |
+
if __name__ == "__main__":
|
| 153 |
+
main()
|
pages/claim-1-under-finite-drift-energy-assumptions-the-intra-generation-kl-divergence-between-the-generated-distribution-and-the-training-target-is-bounded-above-by-1-2-the-learned-path-score-error-energy-proposition-3-1/page.md
CHANGED
|
@@ -56,3 +56,18 @@ python3 -W error code/scope_influential_broad_audit.py
|
|
| 56 |
|
| 57 |
Source pins: PDF `fe979c798cd48a5af02f6c647ecc29b2d6a937841adfa8ceedb492b1c2d81583`;
|
| 58 |
archive `729a62da953ae2f9458f5e938ba53a7d6dbd8efbac6f079028fa6af6df0c0a06`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
Source pins: PDF `fe979c798cd48a5af02f6c647ecc29b2d6a937841adfa8ceedb492b1c2d81583`;
|
| 58 |
archive `729a62da953ae2f9458f5e938ba53a7d6dbd8efbac6f079028fa6af6df0c0a06`.
|
| 59 |
+
|
| 60 |
+
### State-dependent non-Gaussian path audit (20260730)
|
| 61 |
+
|
| 62 |
+
The new CPU producer `code/non_gaussian_path_scope_audit.py` replaces the
|
| 63 |
+
Gaussian-endpoint-only check with a state-dependent path. The reference path
|
| 64 |
+
is Brownian and the perturbed path has drift `a*x`; the initial law is a
|
| 65 |
+
non-Gaussian three-, four-, or seven-mode mixture. OU component means and
|
| 66 |
+
variances, the integrated drift energy, and both endpoint densities are
|
| 67 |
+
evaluated directly, without samples or training. It covers `a` in
|
| 68 |
+
`{-0.15,-0.10,-0.05,0.05,0.10,0.15}` and independent dimensions
|
| 69 |
+
`1,2,4,8`: **72 exact product cells**. Every endpoint KL satisfies the
|
| 70 |
+
half-energy upper bound; the largest measured `KL/(energy/2)` is
|
| 71 |
+
**0.717057755**, and the maximum density-mass normalization error is
|
| 72 |
+
**2.22e-16**. This directly adds non-Gaussian, state-dependent diffusion paths
|
| 73 |
+
to the prior Gaussian and analytic-family evidence.
|
pages/claim-3-combining-the-upper-and-lower-bounds-yields-a-two-sided-equivalence-p-i-1-q-in-the-perturbative-regime-theorem-3-4/page.md
CHANGED
|
@@ -52,3 +52,18 @@ Gaussian/linear family while retaining the theorem's constant-dependent scope.
|
|
| 52 |
```bash
|
| 53 |
python3 -W error code/scope_influential_broad_audit.py
|
| 54 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
```bash
|
| 53 |
python3 -W error code/scope_influential_broad_audit.py
|
| 54 |
```
|
| 55 |
+
|
| 56 |
+
### State-dependent non-Gaussian equivalence audit (20260730)
|
| 57 |
+
|
| 58 |
+
The same `code/non_gaussian_path_scope_audit.py` run computes endpoint
|
| 59 |
+
chi-squared divergence and path energy on the 72 non-Gaussian state-dependent
|
| 60 |
+
cells described for Claim 1. Every observable cell has positive chi-squared
|
| 61 |
+
divergence. Across all dimensions and drifts, `χ²/energy` ranges from
|
| 62 |
+
**0.214829988** to **1.649887777**; restricting to the perturbative
|
| 63 |
+
`|a|<=0.10` cells gives **0.231938679--0.931348912**. Four deterministic
|
| 64 |
+
mean-zero-in-time controls have positive path energies
|
| 65 |
+
`0.0025,0.01,0.04,0.16` and exactly zero endpoint chi-squared divergence,
|
| 66 |
+
so the positive-equivalence range excludes zero observability rather than
|
| 67 |
+
silently treating path energy as endpoint distinguishability. The calculation
|
| 68 |
+
uses analytic mixture densities and fixed CPU quadrature, with no Monte Carlo
|
| 69 |
+
or neural model.
|