12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- import numpy.random
- import numpy as np
- import matplotlib.pyplot as plt
- from math import sqrt, pi
- from Tools.Decomp import DataSet
- from Tools.OrthExp import ExpDecompFactory
- end = 12.0
- Npt = 3000
- Nbasis = 128
- Ntrial = 1
- Bsamp = 1e7
- Bmu = 1.0
- Bsig = 2.0
- Lambda = 2.8
- Alpha = 1.9
- x = np.linspace(0, end, Npt)
- dx = float(end)/Npt
- def gaus(x, mu, sigma):
- x = np.array(x)
- return np.exp(-( (x-mu)/sigma)**2/2)/(sigma*sqrt(2*pi))
- np.set_printoptions(precision=3, linewidth=160)
- Factory = ExpDecompFactory(Nthread=4, Nbasis=Nbasis, Lambda=Lambda, x0=0.0, Alpha=Alpha, a=0)
- for n in range(Ntrial):
-
- t = numpy.random.normal(loc=Bmu, scale=Bsig, size=int(Bsamp))
- D = DataSet( t, Factory)
- print "PE: %d/%d; Nevt: %.1f" % (n+1, Ntrial, D.DatNint)
- '''
- Lbest = np.inf
- Pbest = ((0, 0))
- for a in np.linspace(1, 2, 11):
- for l in np.linspace(1, 3, 21):
- L = D.ObjFunc((a, l))
- if L < Lbest:
- Lbest = L
- Pbest = ((a, l))
- D.ObjFunc(Pbest)
- '''
-
- D.FitW()
-
- print "wgt: ", Factory["a"]
- print "Nb: ", D.Test.Nmax
- print "Mom: ", D.Test.Mom
- plt.plot(x, D.Test( x ), color='red', alpha=0.1)
- Tf = (Bsamp/D.DatNint) * np.exp(-( (x-Bmu)/Bsig )**2/2)/(Bsig*sqrt(2*pi))
- plt.plot(x, Tf, lw=2.5, ls='--', color='black')
- plt.yscale('log')
- plt.show()
- exit()
|