def Gs(i, j): return lambda: random.gauss(Qs[0][i, j], math.sqrt(Qs[1][i, j])) import Pymatr.synthesis as Syn from Pymatr.utils import numerical L = red.dEigen nsyn = 100 Gen = Syn.MatrixRngOpt(numerical(A), numerical(E / L), Gs, nsyn) def average(): s = sum(Gen()) av = s / nsyn # print(" \n sum {}, average: {}\n".format(r, av) ) return av lln = red.lln() import Pymatr.byPieces as Bp Bp.plot(lln) import Pymatr.histogram as H nsample = 1000 H.plot(nsample, average) import matplotlib.pyplot as plt #plt.xticks( [ Q1r[0].evalf() ], ["µ"] ) plt.show()
\end{equation} for our example, we have ''') llnLaw = Lim.llnLimit(Q1r, paths, probP) __latex__(r'''% \begin{equation} p \p{ \frac{S(\vec{X})}{N} = s } = ''') __pynclusion__(llnLaw.latex('s')) __latex__(r''' \end{equation} ''') plt.figure(figsize=Pl.fig_center) import Pymatr.byPieces as Bp Pl.limitTicks(5, 4) Bp.plot(llnLaw, plot=lambda x, y: plt.plot(x, y, "k--")) import Pymatr.Histogram as H import math def sample(): s = sum(GenLLN()) return s / nsyn H.plot(nhist, sample, lambda x, y: plt.plot(x, y, "b-")) plt.xlabel("$s$") plt.ylabel("$\Psi(s)$") plt.tight_layout() plt.savefig("Figs/LLN.pdf")
return lambda : random.gauss( Qs[0][i,j], math.sqrt(Qs[1][i,j]) ) import Pymatr.synthesis as Syn from Pymatr.utils import numerical L= red.dEigen nsyn=100 Gen = Syn.MatrixRngOpt(numerical(A),numerical(E/L), Gs, nsyn) def average(): s= sum(Gen()) av= s /nsyn # print(" \n sum {}, average: {}\n".format(r, av) ) return av lln=red.lln() import Pymatr.byPieces as Bp Bp.plot(lln) import Pymatr.histogram as H nsample=1000 H.plot(nsample, average) import matplotlib.pyplot as plt #plt.xticks( [ Q1r[0].evalf() ], ["µ"] ) plt.show()
\end{equation} for our example, we have ''') llnLaw=Lim.llnLimit(Q1r,paths,probP) __latex__(r'''% \begin{equation} p \p{ \frac{S(\vec{X})}{N} = s } = ''') __pynclusion__(llnLaw.latex('s')) __latex__(r''' \end{equation} ''') plt.figure(figsize=Pl.fig_center ) import Pymatr.byPieces as Bp Pl.limitTicks(5,4) Bp.plot(llnLaw, plot=lambda x,y : plt.plot(x,y,"k--")) import Pymatr.Histogram as H import math def sample(): s= sum(GenLLN()) return s/nsyn H.plot(nhist, sample, lambda x,y : plt.plot(x,y,"b-") ) plt.xlabel("$s$") plt.ylabel("$\Psi(s)$" ) plt.tight_layout() plt.savefig("Figs/LLN.pdf") plt.savefig("Figs/LLN.svg") __latex__(r'''%