<jupyter_start><jupyter_text>Method 1, polyfit()<jupyter_code>m_fit, b_fit=np.poly1d(np.polyfit(x,y,1,w=1./y_err))
print(m_fit, b_fit)

y_fit=m_fit*x+b_fit<jupyter_output><empty_output><jupyter_text>Plot result<jupyter_code>f=plt.figure(figsize=(7,7))
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(loc=2,frameon=False)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.20470588235294118, 'fraction_numerical': 0.01647058823529412, 'mean_word_length': 16.75, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '214573', 'license': 'MIT', 'n_tokens_mistral': 222, 'n_tokens_neox': 211, 'n_words': 13, 'path': 'line_fitting.ipynb', 'repo_name': 'PetersonZou/ASTR-119-Session-6', 'size': '425'}