diff --git a/docs/FIGURE_GALLERY.md b/docs/FIGURE_GALLERY.md index 9e80d14..9a8077a 100644 --- a/docs/FIGURE_GALLERY.md +++ b/docs/FIGURE_GALLERY.md @@ -37,3 +37,9 @@ [配对报告](../results/finetune-comparison/REPORT.md) · [CDF](../results/finetune-comparison/figures/paired_effective_heads_cdf.png) · [逐层分布](../results/finetune-comparison/figures/paired_effective_heads_by_layer.png) · [配对变化](../results/finetune-comparison/figures/paired_effective_heads_delta.png) 同目录保留PDF/SVG。图表随代码、原始数据和SHA清单一同提交,不依赖聊天附件。 + +## 高维壳与稀疏性对照 + +![稀疏球壳对照](../results/sparse-shell/sparse_shell_controls.png) + +[条件定理、反例与数据说明](../results/sparse-shell/REPORT.md) · [PDF](../results/sparse-shell/sparse_shell_controls.pdf) · [SVG](../results/sparse-shell/sparse_shell_controls.svg) diff --git a/results/sparse-shell/REPORT.md b/results/sparse-shell/REPORT.md new file mode 100644 index 0000000..d93af84 --- /dev/null +++ b/results/sparse-shell/REPORT.md @@ -0,0 +1,22 @@ +# 稀疏分布与高维壳:条件定理及反例 + +在同一外半径R下,若X在d维球内均匀分布,P(||X||<=aR)=a^d。若X均匀分布于嵌入该空间的k维子空间球,则概率为a^k。0a^d。 + +因此用户猜想在上述模型下成立。k仍很大时也有薄壳,只是由有效维度k决定,而非环境维度d。 + +| r/R | 128维均匀球(理论) | 16维子空间均匀球(理论) | 内部概率倍数 | +|---|---:|---:|---:| +| 0.8 | 3.9402e-13 | 0.0281475 | 7.14367e+10 | +| 0.9 | 1.39008e-06 | 0.185302 | 133303 | +| 0.95 | 0.00140806 | 0.440127 | 312.576 | +| 0.99 | 0.276252 | 0.851458 | 3.08218 | + +模拟构造4组实际128维向量,每组20000个,再测量其范数:全维均匀球、16维子空间均匀球、同样16稀疏但采用原128维球半径分布、以及全部固定在半径R的16稀疏点。前两者验证条件定理;后两者说明仅凭稀疏不能保证内部概率增加。 + +所有组外半径相同,但平均范数并未强行匹配。若把每个向量都归一化为相同范数,径向差异会被直接抹去。固定半径组的浮点误差约1e-16;理论上全部在球面,图中仅为数值表示。 + +这不证明好模型的参数更靠内部。用于模型时还需明确采样单元、中心、半径和缩放约定;参数可做保持功能的重参数化,原点距离不是模型质量不变量。 + +文件:run.py为生成程序;measured-radii.npz为全部实测范数;interior-probabilities.csv保留理论与经验概率;三种图格式及SHA清单便于长期保存。没有读取、训练或改动任何模型。 + +有限样本说明:每组20000个点不足以精确估计约1e-6的极小尾概率;极小概率和倍数以解析公式为准,不把零次命中当成严格零概率。 diff --git a/results/sparse-shell/audit.json b/results/sparse-shell/audit.json new file mode 100644 index 0000000..c51056d --- /dev/null +++ b/results/sparse-shell/audit.json @@ -0,0 +1,41 @@ +{ + "passed": true, + "ambient_dimension": 128, + "sparse_dimensions": 16, + "sample_count_per_distribution": 20000, + "seed": 20261111, + "outer_radius": 1, + "controls": { + "uniform_d_ball": { + "active_dimensions": 128, + "max_norm": 0.9999994375833048, + "mean_squared_norm": 0.9846031601593415, + "radial_dimension": 128 + }, + "uniform_k_ball": { + "active_dimensions": 16, + "max_norm": 0.999996278718437, + "mean_squared_norm": 0.8894302831319619, + "radial_dimension": 16 + }, + "sparse_same_radial": { + "active_dimensions": 16, + "max_norm": 0.9999995857902936, + "mean_squared_norm": 0.9847321079586993, + "radial_dimension": 128 + }, + "sparse_sphere": { + "active_dimensions": 16, + "max_norm": 1.0000000000000002, + "mean_squared_norm": 1.0, + "radial_dimension": null + } + }, + "elapsed_seconds": 3.858549994882196, + "limitations": [ + "synthetic distributions, not trained-network parameters", + "same outer radius, not same mean squared norm", + "changing angular support alone leaves the chosen radial law unchanged", + "fixed-radius shell is a deliberately structured counterexample" + ] +} diff --git a/results/sparse-shell/checksums.json b/results/sparse-shell/checksums.json new file mode 100644 index 0000000..6b566d8 --- /dev/null +++ b/results/sparse-shell/checksums.json @@ -0,0 +1,9 @@ +{ + "REPORT.md": "aca991f55ab215f637e310430eef267b0d2a327bb11be5ebdefb8a759fe5a4e5", + "audit.json": "a9c294b86872676ad2cd721d6e4ab819f01ecb43194829246d2505d2fa5a4555", + "interior-probabilities.csv": "e1aaddec9b4079d212a43c05b2b348e449bb6a120314225558ed4a7624de7f28", + "measured-radii.npz": "6a44587524196f4281f43753c87146344a38b72e141d7c06135385cd680b613c", + "sparse_shell_controls.pdf": "d2f749b107b391b58a5309ad14383c41716dc864c0e24d2b517cc1f8f6aa6da2", + "sparse_shell_controls.png": "7d4a6810838a7d377e0e68f19a952baa6784e3fa5a112396f5cbd65e61992eb1", + "sparse_shell_controls.svg": "b34aa1f561b316c06d0c620f594c1e3a64bcaa1ce2cb175d69946e867822b43d" +} diff --git a/results/sparse-shell/interior-probabilities.csv b/results/sparse-shell/interior-probabilities.csv new file mode 100644 index 0000000..a796650 --- /dev/null +++ b/results/sparse-shell/interior-probabilities.csv @@ -0,0 +1,17 @@ +distribution,radius_fraction,theory_probability,empirical_probability,sample_count +uniform_d_ball,0.8,3.940200619639476e-13,0.0,20000 +uniform_k_ball,0.8,0.028147497671065624,0.02645,20000 +sparse_same_radial,0.8,3.940200619639476e-13,0.0,20000 +sparse_sphere,0.8,0.0,0.0,20000 +uniform_d_ball,0.9,1.3900845237714517e-06,0.0,20000 +uniform_k_ball,0.9,0.18530201888518416,0.1821,20000 +sparse_same_radial,0.9,1.3900845237714517e-06,0.0,20000 +sparse_sphere,0.9,0.0,0.0,20000 +uniform_d_ball,0.95,0.001408061023535215,0.0012,20000 +uniform_k_ball,0.95,0.44012666865176536,0.4402,20000 +sparse_same_radial,0.95,0.001408061023535215,0.0011,20000 +sparse_sphere,0.95,0.0,0.0,20000 +uniform_d_ball,0.99,0.2762516676992083,0.27975,20000 +uniform_k_ball,0.99,0.8514577710948755,0.8515,20000 +sparse_same_radial,0.99,0.2762516676992083,0.27645,20000 +sparse_sphere,0.99,0.0,0.0,20000 diff --git a/results/sparse-shell/measured-radii.npz b/results/sparse-shell/measured-radii.npz new file mode 100644 index 0000000..5448b30 Binary files /dev/null and b/results/sparse-shell/measured-radii.npz differ diff --git a/results/sparse-shell/sparse_shell_controls.pdf b/results/sparse-shell/sparse_shell_controls.pdf new file mode 100644 index 0000000..e761576 Binary files /dev/null and b/results/sparse-shell/sparse_shell_controls.pdf differ diff --git a/results/sparse-shell/sparse_shell_controls.png b/results/sparse-shell/sparse_shell_controls.png new file mode 100644 index 0000000..d0b7fa6 Binary files /dev/null and b/results/sparse-shell/sparse_shell_controls.png differ diff --git a/results/sparse-shell/sparse_shell_controls.svg b/results/sparse-shell/sparse_shell_controls.svg new file mode 100644 index 0000000..1d55c18 --- /dev/null +++ b/results/sparse-shell/sparse_shell_controls.svg @@ -0,0 +1,4392 @@ + + + + + + + + 2026-11-11T23:18:47.578801 + image/svg+xml + + + Matplotlib v3.11.2, https://matplotlib.org/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/shell_study/run.py b/shell_study/run.py new file mode 100644 index 0000000..87c4e66 --- /dev/null +++ b/shell_study/run.py @@ -0,0 +1,49 @@ +"""Synthetic geometric controls; no model weights, training or GPU.""" +import argparse,json,csv,hashlib,time +from pathlib import Path +import numpy as np +import matplotlib +matplotlib.use('Agg') +import matplotlib.pyplot as plt + +def main(root): + root=Path(root);root.mkdir(parents=True,exist_ok=False);started=time.monotonic();rng=np.random.default_rng(20261111);d,k,n=128,16,20000 + # Construct actual vectors, then measure norms. Inactive coordinates are zero. + radii={};checks={} + for name,active,radial_dim in [('uniform_d_ball',d,d),('uniform_k_ball',k,k),('sparse_same_radial',k,d),('sparse_sphere',k,None)]: + direction=rng.normal(size=(n,active));direction/=np.linalg.norm(direction,axis=1,keepdims=True) + radius=np.ones(n) if radial_dim is None else rng.uniform(size=n)**(1/radial_dim) + vectors=np.zeros((n,d));vectors[:,:active]=direction*radius[:,None] + measured=np.linalg.norm(vectors,axis=1);np.testing.assert_allclose(measured,radius,atol=1e-14) + checks[name]={'active_dimensions':active,'max_norm':float(measured.max()),'mean_squared_norm':float(np.mean(measured**2)),'radial_dimension':radial_dim} + radii[name]=measured;del vectors,direction + np.savez_compressed(root/'measured-radii.npz',**radii) + rows=[] + for a in [.8,.9,.95,.99]: + for name,x in radii.items(): + m=checks[name]['radial_dimension'];theory=0. if m is None else a**m;empirical=float(np.mean(x<=a)) + # Six standard errors plus finite-sample allowance; diagnostic, not a model-quality claim. + assert abs(empirical-theory)<=6*np.sqrt(theory*(1-theory)/n)+6/n + rows.append({'distribution':name,'radius_fraction':a,'theory_probability':theory,'empirical_probability':empirical,'sample_count':n}) + with (root/'interior-probabilities.csv').open('w') as f: + w=csv.DictWriter(f,fieldnames=list(rows[0]));w.writeheader();w.writerows(rows) + fig,axs=plt.subplots(1,2,figsize=(12,4.5),layout='constrained');labels={'uniform_d_ball':'Uniform 128D ball','uniform_k_ball':'Uniform 16D ball embedded in 128D','sparse_same_radial':'16-sparse, same radii as 128D ball law','sparse_sphere':'16-sparse, fixed radius 1'} + styles=['-','-','--',':'] + for (name,x),style in zip(radii.items(),styles): + xx=np.sort(x);yy=np.arange(1,n+1)/n;axs[0].plot(xx,yy,style,label=labels[name]);axs[1].plot(xx,yy,style,label=labels[name]) + axs[0].set(xlim=(.65,1.005),ylim=(0,1),xlabel='Measured norm / common radius R',ylabel='Interior probability: P(norm <= r)',title='Empirical radial CDF') + axs[1].set(xlim=(.97,1.001),ylim=(0,1),xlabel='Measured norm / R',title='Near-boundary detail') + for ax in axs:ax.grid(alpha=.2) + axs[0].legend(fontsize=8,loc='upper left');fig.suptitle('Same ambient dimension and outer radius; sparsity alone does not fix radial probability') + for ext in ['png','pdf','svg']:fig.savefig(root/('sparse_shell_controls.'+ext),dpi=180) + proof={'passed':True,'ambient_dimension':d,'sparse_dimensions':k,'sample_count_per_distribution':n,'seed':20261111,'outer_radius':1,'controls':checks,'elapsed_seconds':time.monotonic()-started,'limitations':['synthetic distributions, not trained-network parameters','same outer radius, not same mean squared norm','changing angular support alone leaves the chosen radial law unchanged','fixed-radius shell is a deliberately structured counterexample']} + (root/'audit.json').write_text(json.dumps(proof,indent=2)+'\n') + lines=['# 稀疏分布与高维壳:条件定理及反例','', '在同一外半径R下,若X在d维球内均匀分布,P(||X||<=aR)=a^d。若X均匀分布于嵌入该空间的k维子空间球,则概率为a^k。0a^d。','', '因此用户猜想在上述模型下成立。k仍很大时也有薄壳,只是由有效维度k决定,而非环境维度d。','', '| r/R | 128维均匀球(理论) | 16维子空间均匀球(理论) | 内部概率倍数 |','|---|---:|---:|---:|'] + for a in [.8,.9,.95,.99]:lines.append(f'| {a} | {a**d:.6g} | {a**k:.6g} | {a**(k-d):.6g} |') + lines+=['', '模拟构造4组实际128维向量,每组20000个,再测量其范数:全维均匀球、16维子空间均匀球、同样16稀疏但采用原128维球半径分布、以及全部固定在半径R的16稀疏点。前两者验证条件定理;后两者说明仅凭稀疏不能保证内部概率增加。','', '所有组外半径相同,但平均范数并未强行匹配。若把每个向量都归一化为相同范数,径向差异会被直接抹去。固定半径组的浮点误差约1e-16;理论上全部在球面,图中仅为数值表示。','', '这不证明好模型的参数更靠内部。用于模型时还需明确采样单元、中心、半径和缩放约定;参数可做保持功能的重参数化,原点距离不是模型质量不变量。','', '文件:run.py为生成程序;measured-radii.npz为全部实测范数;interior-probabilities.csv保留理论与经验概率;三种图格式及SHA清单便于长期保存。没有读取、训练或改动任何模型。'] + lines+=['', '有限样本说明:每组20000个点不足以精确估计约1e-6的极小尾概率;极小概率和倍数以解析公式为准,不把零次命中当成严格零概率。'] + (root/'REPORT.md').write_text('\n'.join(lines)+'\n') + (root/'checksums.json').write_text(json.dumps({p.name:hashlib.sha256(p.read_bytes()).hexdigest() for p in sorted(root.iterdir()) if p.is_file()},indent=2)+'\n') + print((root/'REPORT.md').read_text(),end='') +if __name__=='__main__': + p=argparse.ArgumentParser();p.add_argument('--out',required=True);a=p.parse_args();main(a.out)