<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 <h1>Table of Contents<span class="tocSkip"></span></h1>
<div class="toc"><ul class="toc-item"><li><span><a href="#-Fit-real-histogram" data-toc-modified-id="-Fit-real-histogram-1"><span class="toc-item-num">1&nbsp;&nbsp;</span> Fit real histogram</a></span><ul class="toc-item"><li><span><a href="#-Create-normally-distributed-data" data-toc-modified-id="-Create-normally-distributed-data-1.1"><span class="toc-item-num">1.1&nbsp;&nbsp;</span> Create normally distributed data</a></span></li><li><span><a href="#-Obtain-the-fitting-to-a-normal-distribution" data-toc-modified-id="-Obtain-the-fitting-to-a-normal-distribution-1.2"><span class="toc-item-num">1.2&nbsp;&nbsp;</span> Obtain the fitting to a normal distribution</a></span></li><li><span><a href="#-Get-the-histogram-data-from-NumPy" data-toc-modified-id="-Get-the-histogram-data-from-NumPy-1.3"><span class="toc-item-num">1.3&nbsp;&nbsp;</span> Get the histogram data from NumPy</a></span></li><li><span><a href="#-Scale-the-normal-PDF-to-the-area-of-the-histogram" data-toc-modified-id="-Scale-the-normal-PDF-to-the-area-of-the-histogram-1.4"><span class="toc-item-num">1.4&nbsp;&nbsp;</span> Scale the normal PDF to the area of the histogram</a></span></li></ul></li></ul></div>
<H1> Fit real histogram</H1>
Step1:  <H2> Create normally distributed data</H2>
Step2:  <H2> Obtain the fitting to a normal distribution</H2>
<P> This is simply the mean and the standard deviation of the sample data<P>
Step3:  To adapt the normalized PDF of the normal distribution we simply have to multiply every value by the area of the histogram obtained
<H2> Get the histogram data from NumPy</H2>
Step4:  <H2> Scale the normal PDF to the area of the histogram</H2>
<ASSISTANT_TASK:>
Python Code:
%pylab inline
from scipy.stats import norm
Explanation: <h1>Table of Contents<span class="tocSkip"></span></h1>
<div class="toc"><ul class="toc-item"><li><span><a href="#-Fit-real-histogram" data-toc-modified-id="-Fit-real-histogram-1"><span class="toc-item-num">1&nbsp;&nbsp;</span> Fit real histogram</a></span><ul class="toc-item"><li><span><a href="#-Create-normally-distributed-data" data-toc-modified-id="-Create-normally-distributed-data-1.1"><span class="toc-item-num">1.1&nbsp;&nbsp;</span> Create normally distributed data</a></span></li><li><span><a href="#-Obtain-the-fitting-to-a-normal-distribution" data-toc-modified-id="-Obtain-the-fitting-to-a-normal-distribution-1.2"><span class="toc-item-num">1.2&nbsp;&nbsp;</span> Obtain the fitting to a normal distribution</a></span></li><li><span><a href="#-Get-the-histogram-data-from-NumPy" data-toc-modified-id="-Get-the-histogram-data-from-NumPy-1.3"><span class="toc-item-num">1.3&nbsp;&nbsp;</span> Get the histogram data from NumPy</a></span></li><li><span><a href="#-Scale-the-normal-PDF-to-the-area-of-the-histogram" data-toc-modified-id="-Scale-the-normal-PDF-to-the-area-of-the-histogram-1.4"><span class="toc-item-num">1.4&nbsp;&nbsp;</span> Scale the normal PDF to the area of the histogram</a></span></li></ul></li></ul></div>
<H1> Fit real histogram</H1>
End of explanation
# fake some data
data = norm.rvs(loc=0.0, scale=1.0, size =150)
plt.hist(data, rwidth=0.85, facecolor='black');
plt.ylabel('Number of events');
plt.xlabel('Value');
Explanation: <H2> Create normally distributed data</H2>
End of explanation
mean, stdev = norm.fit(data)
print('Mean =%f, Stdev=%f'%(mean,stdev))
Explanation: <H2> Obtain the fitting to a normal distribution</H2>
<P> This is simply the mean and the standard deviation of the sample data<P>
End of explanation
histdata = plt.hist(data, bins=10, color='black', rwidth=.85) # we set 10 bins
counts, binedge = np.histogram(data, bins=10);
print(binedge)
#G et bincenters from bin edges
bincenter = [0.5 * (binedge[i] + binedge[i+1]) for i in xrange(len(binedge)-1)]
bincenter
binwidth = (max(bincenter) - min(bincenter)) / len(bincenter) 
print(binwidth)
Explanation: To adapt the normalized PDF of the normal distribution we simply have to multiply every value by the area of the histogram obtained
<H2> Get the histogram data from NumPy</H2>
End of explanation
x = np.linspace( start = -4 , stop = 4, num = 100)
mynorm = norm(loc = mean, scale = stdev)
# Scale Norm PDF to the area (binwidth)*number of samples of the histogram
myfit = mynorm.pdf(x)*binwidth*len(data)
# Plot everthing together
plt.hist(data, bins=10, facecolor='white', histtype='stepfilled');
plt.fill(x, myfit, 'r', alpha=.5);
plt.ylabel('Number of observations');
plt.xlabel('Value');
Explanation: <H2> Scale the normal PDF to the area of the histogram</H2>
End of explanation
<END_TASK>