Datasets:
Formats:
json
Languages:
English
Size:
< 1K
Tags:
mathematical-physics
arrow-of-time
temporal-irreversibility
time-reversal-symmetry
quantum-information
quantum-foundations
File size: 4,430 Bytes
ee3d849 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | #!/usr/bin/env python3
"""Reproduce illustrative model figures. No fitted or measured data."""
from pathlib import Path
import json
import numpy as np
import scipy
from scipy.stats import binom
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
ROOT = Path(__file__).resolve().parents[1]
OUT = ROOT / "figures"
OUT.mkdir(exist_ok=True)
plt.rcParams.update({"font.family":"DejaVu Sans","font.size":11,
"axes.spines.top":False,"axes.spines.right":False,
"axes.titleweight":"bold","axes.titlesize":11,"pdf.fonttype":42,"figure.dpi":140})
ink="#132e3a"; teal="#237f82"; amber="#b86128"; gray="#79888f"
n=np.arange(1,1001)
eps=0.35
def bayes_error(m):
m=np.asarray(m)
# For p=3/4 against q=1/4; symmetry equates the two error probabilities.
lower=np.floor((m-1)/2).astype(int)
return binom.cdf(lower,m,.75)+np.where(m%2==0,.5*binom.pmf(m//2,m,.75),0)
m=np.floor(np.sqrt(n)).astype(int)
one_kl=.5*np.log(3.)
fig, ax=plt.subplots(1,2,figsize=(8,3.6),layout="constrained")
ax[0].plot(n,bayes_error(m),color=teal,label="Sparse evidence at square times")
ax[0].plot(n,(1-eps)/2+eps*bayes_error(n),color=amber,label="Shared sector of mass 0.65")
ax[0].axhline((1-eps)/2,color=amber,ls=":",lw=1)
ax[0].set(xlabel="Retained history length n",ylabel="Optimal direction error",
ylim=(-.01,.42),title="Direction recognition")
ax[0].legend(frameon=False,loc="upper right",fontsize=9)
ax[1].plot(n,m*one_kl/n,color=teal)
ax[1].plot(n,np.full(n.shape,eps*one_kl),color=amber)
ax[1].set(xlabel="Retained history length n",ylabel="D(Pₙ ∥ Qₙ) / n [nats]",
title="Linear information rate")
for a in ax: a.grid(axis="y",alpha=.15)
fig.savefig(OUT/"persistence.pdf")
fig.savefig(OUT/"persistence.png",dpi=170)
plt.close(fig)
q=json.loads((ROOT/"verification"/"quantum_results.json").read_text())
c=q["counterexample"]
fig,axes=plt.subplots(1,3,figsize=(8,3.6),layout="constrained")
x=np.arange(2);labels=["Record 0","Record 1"]
axes[0].bar(x-.16,[.15,-.15],width=.32,label="Source via K+",color=teal)
axes[0].bar(x+.16,[-.15,.15],width=.32,label="Protocol via K−",color=amber)
axes[0].axhline(0,color=ink,lw=.8)
axes[0].set(xticks=x,xticklabels=labels,ylabel="Signed contrast mass",
title="Source and detector\ncancel exactly",ylim=(-.21,.24))
axes[0].legend(frameon=False,fontsize=9)
axes[1].bar(x,[c["score_in"],c["score_out"]],color=[teal,gray],width=.55)
axes[1].set(xticks=x,xticklabels=["Input","Dephased"],ylabel="Quadratic score energy",
title="Quadratic score\nis preserved",ylim=(0,.20))
for i in x: axes[1].text(i,.166,"0.16",ha="center",fontsize=9)
axes[2].bar(x,[c["js_in"],c["js_out"]],color=[teal,gray],width=.55)
axes[2].set(xticks=x,xticklabels=["Input","Dephased"],ylabel="Quantum JS [nats]",
title="Quantum information\nis lost",ylim=(0,.12))
for i,v in enumerate([c["js_in"],c["js_out"]]):
axes[2].text(i,v+.003,f"{v:.5f}",ha="center",fontsize=9)
for a in axes: a.grid(axis="y",alpha=.15)
fig.savefig(OUT/"protocol_quantum.pdf")
fig.savefig(OUT/"protocol_quantum.png",dpi=170)
plt.close(fig)
fig,ax=plt.subplots(1,2,figsize=(8,3.6),layout="constrained")
xx=np.arange(3)
ax[0].bar(xx-.16,np.ones(3)/3,.32,label="Original clock",color=teal)
ax[0].bar(xx+.16,np.array([4,2,1])/7,.32,label="Speeds (1, 2, 4)",color=amber)
ax[0].set(xticks=xx,xticklabels=["State 1","State 2","State 3"],
ylabel="Stationary probability",title="Inverse-speed occupancy",ylim=(0,.65))
ax[0].legend(frameon=False,fontsize=9)
ax[1].bar([0,1],[np.log(2)/3,np.log(2)/3],color=[teal,amber],width=.55)
ax[1].set(xticks=[0,1],xticklabels=["Original clock","Changed clock"],
ylabel="Irreversibility per jump [nats]",
title="Information per event",ylim=(0,.29))
ax[1].text(.5,.25,"log(2) / 3 ≈ 0.231049",ha="center",fontsize=9)
for a in ax: a.grid(axis="y",alpha=.15)
fig.savefig(OUT/"event_clock.pdf")
fig.savefig(OUT/"event_clock.png",dpi=170)
plt.close(fig)
(ROOT/"verification"/"results"/"figure_metadata.json").write_text(
json.dumps({"kind":"illustrative declared models; no measured data",
"numpy":np.__version__,"scipy":scipy.__version__,"matplotlib":matplotlib.__version__,
"files":["persistence.pdf","protocol_quantum.pdf","event_clock.pdf"],
"sparse_bernoulli_p":.75,"mixture_active_mass":eps,
"quantum_pair":{"r":.6,"a":.4}},indent=2)+"\n")
print("Generated 3 vector PDF figures and PNG previews.")
|