---
# System prepended metadata

title: import numpy as npimport math

---

import numpy as np
import math

def calculate_regressionCoeff(A, B):
    # theta = (A_t @ A)^(-1) @ A_t @ b
    res1 = (A.T@A)
    res2 = np.linalg.inv(res1)@ A.T
    print(res2)
    res = res2 @ B
    return res
    
A = np.array([
    [1,1,1],
    [1,2,3],
    [1,3,4],
    [1,4,3]
])

B = np.array([
    [1],
    [3],
    [4],
    [5]
])

res = calculate_regressionCoeff(A, B)
print(res)

R = A @ res - B #R laf sai so, 
val_R = math.sqrt(R.T@R)
print(val_R)