<jupyter_start><jupyter_text>Least Square<jupyter_code>import numpy as np

x = np.array([1, 2, 3])
y = np.array([23, 24, 27])

A = np.vstack([x, np.ones(len(x))]).T
b1, b2 = np.linalg.lstsq(A, y)[0]
print(b1,b2)
import matplotlib.pyplot as plt
plt.plot(x, y, 'o', label='Original data', markersize=10)
plt.plot(x, b1*x + b2, 'r', label='Fitted line')
plt.legend()
plt.show()<jupyter_output><empty_output><jupyter_text>ยกกำลังสองพจน์ $(x+y+c)^{2}$<jupyter_code>y1   = np.array([[-1,-1,23]])
y1sq = np.kron(y1,y1)
y2   = np.array([[-2,-1,24]])
y2sq = np.kron(y2,y2)
y3   = np.array([[-3,-1,27]])
y3sq = np.kron(y3,y3)

deltaS = y1sq+y2sq+y3sq
deltaS<jupyter_output><empty_output><jupyter_text>Solve 2 Variable Equation*SolveSolve the system of equations 3 * x0 + x1 = 9 and x0 + 2 * x1 = 8:*<jupyter_code>a = np.array([[28,12], [12,6]])
b = np.array([304,148])
x = np.linalg.solve(a, b)
x<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.2183406113537118, 'fraction_numerical': 0.07423580786026202, 'mean_word_length': 5.742647058823529, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '500292', 'license': 'Apache-2.0', 'n_tokens_mistral': 489, 'n_tokens_neox': 463, 'n_words': 78, 'path': '2 - Least square for linear model.ipynb', 'repo_name': 'Kanbc/kanbc-xyz-python-code', 'size': '916'}