<jupyter_start><jupyter_text>Generate some random data about a trend line.<jupyter_code>np.random.seed(119)

npoints =50

x=np.linspace(0,10.0,npoints)

m = 2.0
b = 1.0

sigma = 2.0

y= m*x + b + np.random.normal(scale=sigma, size=npoints)
y_err = np.full(npoints, sigma)
f = plt.figure(figsize=(7,7))

plt.errorbar(x,y,yerr=y_err, fmt='o')

plt.xlabel('x')
plt.ylabel('y')
m_fit, b_fit = np.poly1d(np.polyfit(x,y,1,w=1.0/y_err))
print(m_fit, b_fit )

y_fit = m_fit* x + b_fit
plt.errorbar(x,y,yerr=y_err, fmt='o',label='data')
plt.plot(x,y_fit,label='fit')
plt.xlabel('x')
plt.ylabel('y')
plt.legend()
m_A = 0.0
m_B = 0.0
m_C = 0.0
m_D = 0.0

m_A = np.sum(x*y)
m_B = np.sum(x)*np.sum(y)
m_C = np.sum(x*x)
m_D = np.sum(x)**2

m_fit_lr = (float(npoints)*m_A - m_B)/(float(npoints)*m_C - m_D)

y_mean = np.mean(y)
x_mean = np.mean(x)

b_fit_lr = y_mean - m_fit_lr * x_mean

y_fit_lr = m_fit_lr*x+ b_fit_lr

print(m_fit_lr, b_fit_lr)
plt.errorbar(x,y,yerr=y_err, fmt='o',label='data')

plt.plot(x,y_fit_lr,'o',label='data')


plt.plot(x,y_fit,label='fit')

plt.xlabel('x')
plt.ylabel('y')
plt.legend()
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.21071115013169447, 'fraction_numerical': 0.02633889376646181, 'mean_word_length': 5.368715083798882, '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': '291578', 'license': 'MIT', 'n_tokens_mistral': 634, 'n_tokens_neox': 604, 'n_words': 87, 'path': 'Linear Regression(1).ipynb', 'repo_name': 'jvelasq9/Astro_119_Dec_4', 'size': '1139'}