<jupyter_start><jupyter_text>Centroid at number 816<jupyter_code>data[816]
peakdata = data[816-50:816+50]
domain = np.arange(816-50,816+50,1)
xpoints = domain
ypoints = peakdata
plt.plot(domain,peakdata);
mu = 816
sigma = np.sqrt(816)
sigma = 15
def myfun(n,a,b,c,sigma,mu):
    ans = a*np.exp(-((n - mu)**2)/(2*sigma**2)) + b*n + c  # this is y, "the function to be fit"
    return ans
p0 = [100,0,50,15,816]
xlots = np.linspace(816-60,816+60)  # need lots of data points for smooth curve
yfit = np.zeros((len(xpoints),xlots.size))

plsq, pcov = curve_fit(myfun, xpoints, ypoints, p0)  # curve fit returns p and covariance matrix
# these give the parameters and the uncertainties
a = plsq[0]
ea = np.sqrt(pcov[0,0])
b = plsq[1]
eb = np.sqrt(pcov[1,1])
c = plsq[2]
ec = np.sqrt(pcov[2,2])

o = plsq[3]
eo = np.sqrt([pcov[3,3]])

mu = plsq[4]
emu = np.sqrt([pcov[4,4]])

yfit = myfun(xlots,plsq[0],plsq[1],plsq[2],plsq[3],plsq[4])  # use fit results for a, b, c
    
print('a = %.7f +/- %.7f' % (plsq[0], np.sqrt(pcov[0,0])))
print('b = %.7f +/- %.7f' % (plsq[1], np.sqrt(pcov[1,1])))
print('c = %.7f +/- %.7f' % (plsq[2], np.sqrt(pcov[2,2])))

print('sigma = %.7f +/- %.7f' % (plsq[3], np.sqrt(pcov[3,3])))

print('mu = %.7f +/- %.7f' % (plsq[4], np.sqrt(pcov[4,4])))
plt.figure(figsize=(10,6));
plt.errorbar(xpoints,ypoints,linestyle = '',marker = 'o');


plt.plot(xlots,yfit);
plt.ylim(0,260)
plt.title('Least-squares fit to data');
plt.legend(['data','Fit'],loc='best');
plt.xlabel('x (cm)',fontsize=20);
plt.ylabel('y deflection (cm)',fontsize = 20);
plt.xticks(size = 13);
plt.yticks(size = 13);
data[816]
myfun(816,a,b,c,sigma,mu)
b
c
mu<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.2349073520621638, 'fraction_numerical': 0.07591153616258219, 'mean_word_length': 4.978571428571429, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '326118', 'license': 'MIT', 'n_tokens_mistral': 851, 'n_tokens_neox': 771, 'n_words': 150, 'path': 'GammaAbsorption/AbsorptionFit.ipynb', 'repo_name': 'fraksuh/QLab', 'size': '1673'}