6 import matplotlib.pyplot as plt
8 from scipy.optimize import curve_fit
15 return a * ( x**((g-2)/2) * np.exp( -g*x/(2*Tr) ) )
17 #x,y= np.loadtxt('1L2Y_L_GB000.stat',usecols=(0,10),skiprows=30,unpack=True)
18 #x,y= np.loadtxt('1L2Y_NH_GB000.stat',usecols=(0,11),skiprows=10000,unpack=True)
19 #x,y= np.loadtxt('1L2Y_B_GB000.stat',usecols=(0,10),skiprows=30,unpack=True)
20 if (sys.argv[1] == '1L2Y_NH_GB000.stat' or sys.argv[1] == '1L2Y_NH_GB.stat'):
21 x,y= np.loadtxt(sys.argv[1],usecols=(0,11),skiprows=10000,unpack=True)
23 x,y= np.loadtxt(sys.argv[1],usecols=(0,10),skiprows=10000,unpack=True)
25 h,bin=np.histogram(y,bins=50,density=True)
27 plt.bar(bin[:-1], h, width = bin[2]-bin[1])
28 plt.xlim(min(bin), max(bin))
30 plt.ylabel('probality')
31 plt.xlabel('temperature')
33 center = (bin[:-1] + bin[1:]) / 2
36 popt, pcov = curve_fit(prob_T, center, h, p0=10E-107)
37 xfine = np.linspace(min(bin), max(bin), 100)
40 chi_squared = np.sum((prob_T(center, *popt)-h)**2)
41 print '%15.10f' % chi_squared
44 #print prob_T(xfine,popt[0])
45 plt.plot(xfine,prob_T(xfine,popt[0]),'-',c='red')
46 plt.savefig(sys.argv[1]+'.png')