In[]:=
(*========================================================================*)(*TWISTORSTRINGCLEANALYSIS&1/|u|^3ERRORBOUNDING*)(*========================================================================*)(*1.Loadthedata(Updatefilenametomatchyouractualdatafile)*)data=Import["/Users/amigdal/Documents/Wolfram/QCD/results/TwistorHistory_Node10_E2.29289_K6.mx"];​​rawO=Flatten[data[[All,2]]];​​invOFull=1.0/rawO;​​nCut=2000;​​trimFrac=0.05;​​​​(*========================================================================*)​​(*FIGURE1:FullHistoryandCumulativeMean*)​​(*========================================================================*)​​p1=ListLinePlot[{Re[invOFull],Im[invOFull]},PlotRange->{All,{-15,10}},PlotStyle->{Directive[Blue,AbsoluteThickness[1]],Directive[Red,AbsoluteThickness[1]]},GridLines->{{nCut},{0}},GridLinesStyle->Directive[Black,Dashed,AbsoluteThickness[1.5]],Frame->True,FrameLabel->{"Monte Carlo Step","Raw Instantaneous 1/O"},PlotLegends->Placed[LineLegend[{"Re[1/O]","Im[1/O]"}],Top],BaseStyle->{FontSize->14,FontFamily->"Helvetica"},ImageSize->500];​​Export["history_full_with_cutoff.pdf",p1];​​​​cumMeanRe=Rest[FoldList[Plus,0.0,Re[invOFull]]]/Range[Length[invOFull]];​​cumMeanIm=Rest[FoldList[Plus,0.0,Im[invOFull]]]/Range[Length[invOFull]];​​​​p2=ListLinePlot[{cumMeanRe,cumMeanIm},PlotRange->All,PlotStyle->{Directive[Darker[Blue],Thick],Directive[Darker[Red],Thick]},GridLines->{None,{0}},GridLinesStyle->Directive[Gray,Dashed],Frame->True,FrameLabel->{"Total MCMC Steps","Cumulative Arithmetic Mean"},PlotLegends->Placed[LineLegend[{"<Re>","<Im>"}],Top],BaseStyle->{FontSize->14,FontFamily->"Helvetica"},ImageSize->500];​​Export["history_convergence.pdf",p2];​​​​(*========================================================================*)​​(*FIGURE2&3:KDEHistograms(ThermalizedCore)*)​​(*========================================================================*)​​equilInvO=Drop[invOFull,nCut];​​realDist=Re[equilInvO];​​imagDist=Im[equilInvO];​​​​physVal=TrimmedMean[realDist,trimFrac];​​​​p3=SmoothHistogram[imagDist,PlotRange->{{-2,2},All},Filling->Axis,PlotStyle->Directive[Thick,Darker[Orange]],Frame->True,FrameLabel->{"Im[1/O]","Probability Density"},BaseStyle->{FontSize->14,FontFamily->"Helvetica"},ImageSize->500];​​Export["kde_im_equilibrium.pdf",p3];​​​​p4=SmoothHistogram[realDist,PlotRange->{{-5,5},All},Filling->Axis,PlotStyle->Directive[Thick,Darker[Blue]],GridLines->{{physVal},None},GridLinesStyle->Directive[Red,Thick,Dashed],Frame->True,FrameLabel->{"Re[1/O]","Probability Density"},BaseStyle->{FontSize->14,FontFamily->"Helvetica"},ImageSize->500];​​Export["kde_re_core.pdf",p4];​​​​(*========================================================================*)​​(*EXACT1/|u|^3TAILBOUNDING&LATEXTABLE*)​​(*========================================================================*)​​uL=Quantile[realDist,trimFrac];​​uR=Quantile[realDist,1-trimFrac];​​​​(*AnalyticReconstructedPVMean=Core+LeftTailIntegral+RightTailIntegral*)​​totalReconstructedMean=(1-2*trimFrac)*physVal+2*trimFrac*(uL+uR);​​systematicTailError=Abs[totalReconstructedMean-physVal];​​(*========================================================================*)(*COMPACTLATEXTABLEGENERATOR*)(*========================================================================*)latexTable=StringTemplate["\\begin{table}[htbp]\\centering\\small\\renewcommand{\\arraystretch}{1.2}\\begin{tabular}{@{} l c r @{}}\\hline\\hline\\textbf{Parameter} & \\textbf{Sym.} & \\textbf{Value} \\\\\\hlineTrimmed Core & $\\mu_{\\text{core}}$ & $`1`$ \\\\Left Cut ($5\\%$) & $u_L$ & $`2`$ \\\\Right Cut ($95\\%$) & $u_R$ & $`3`$ \\\\Analytic PV Mean & $\\mu_{\\text{tot}}$ & $`4`$ \\\\\\hline\\textbf{Asym. PV Error} & $\\Delta_{\\text{tail}}$ & $\\mathbf{\\pm `5`}$ \\\\\\hline\\hline\\end{tabular}\\caption{Analytic bounds on finite-sample Cauchy Principal Value (PV) asymmetry, derived from exact $1/|u|^3$ Langevin excursions.}\\label{tab:tail_error}\\end{table}"][ToString[NumberForm[physVal,{7,6}]],ToString[NumberForm[uL,{7,6}]],ToString[NumberForm[uR,{7,6}]],ToString[NumberForm[totalReconstructedMean,{7,6}]],ToString[NumberForm[systematicTailError,{7,6}]]];​​​​Print["\n% === COPY THIS TABLE DIRECTLY INTO YOUR LATEX DOCUMENT ===\n"];​​Print[latexTable];​​​​(*========================================================================*)​​(*FIGURE4:Log-TailDiagnosticwithExactAnalyticalBounds*)​​(*========================================================================*)​​logFitL[x_]:=Log[2*trimFrac*uL^2]-3*Log[Abs[x]];​​logFitR[x_]:=Log[2*trimFrac*uR^2]-3*Log[Abs[x]];​​​​dist=SmoothKernelDistribution[realDist];​​​​p5=Plot[{Log[PDF[dist,x]],logFitL[x],logFitR[x]},{x,-15,15},PlotRange->{{-15,15},{-20,1}},PlotStyle->{Directive[Thick,Darker[Red]],Directive[Thick,Black,Dashed],Directive[Thick,Black,Dashed]},Frame->True,FrameLabel->{"Re[1/O]","Log[Probability Density]"},PlotLegends->Placed[LineLegend[{Directive[Thick,Darker[Red]],Directive[Thick,Black,Dashed]},{"CLE Data","Analytic 1/|u|^3 Bounds"}],Top],BaseStyle->{FontSize->14,FontFamily->"Helvetica"},ImageSize->500];​​Export["kde_re_logtail.pdf",p5];​​​​Print["Successfully generated and exported all 5 PDF plots!"];
% === COPY THIS TABLE DIRECTLY INTO YOUR LATEX DOCUMENT ===
\begin{table}[htbp]\centering\small\renewcommand{\arraystretch}{1.2}\begin{tabular}{@{} l c r @{}}\hline\hline\textbf{Parameter} & \textbf{Sym.} & \textbf{Value} \\\hlineTrimmed Core & $\mu_{\text{core}}$ & $0.141477$ \\Left Cut ($5\%$) & $u_L$ & $-1.327870$ \\Right Cut ($95\%$) & $u_R$ & $1.747024$ \\Analytic PV Mean & $\mu_{\text{tot}}$ & $0.169244$ \\\hline\textbf{Asym. PV Error} & $\Delta_{\text{tail}}$ & $\mathbf{\pm 0.027768}$ \\\hline\hline\end{tabular}\caption{Analytic bounds on finite-sample Cauchy Principal Value (PV) asymmetry, derived from exact $1/|u|^3$ Langevin excursions.}\label{tab:tail_error}\end{table}
Successfully generated and exported all 5 PDF plots!