In [10]:
import numpy as np
import matplotlib.pyplot as plt
import scipy.special as sps
shape, scale = 5., 12.  # mean=4, std=2*sqrt(2)
s1 = np.random.gamma(shape, scale, 1000)
s2 = np.random.gamma(shape*2, scale,1000)
count, bins, ignored = plt.hist(s1, 50)#, normed=True)
plt.hist(s2,50)
plt.hist(s1+s2,50)
#y = bins**(shape-1)*(np.exp(-bins/scale) / (sps.gamma(shape)*scale**shape))
#plt.plot(bins, y, linewidth=2, color='r')
plt.show()



In [27]:
import pandas

In [31]:
df = pandas.read_csv('C:/Users/sysl1_1704a/Documents/2017HISOL/gamma_out.txt',header=None)

In [44]:
plt.figure()
plt.show()
df.plot.hist(bins=150)
plt.show()


<matplotlib.figure.Figure at 0xba57da0>

In [45]:
df.min()


Out[45]:
0    1.834676
dtype: float64

In [46]:
df.max()


Out[46]:
0    871.50397
dtype: float64

In [19]:
y = bins**(shape-1)*(np.exp(-bins/scale) / (sps.gamma(shape)*scale**shape))
plt.plot(bins, y, linewidth=2, color='r')
shape2 = shape * 3
y2 = bins**(shape2-1)*(np.exp(-bins/scale) / (sps.gamma(shape2)*scale**shape2))
plt.plot(bins, y2, linewidth=1, color='b')
plt.plot(bins, y + y2, color='g')
plt.show()



In [ ]: