Skip to content

Instantly share code, notes, and snippets.

View ReticulatedSpline's full-sized avatar

Benjamin Carpenter ReticulatedSpline

View GitHub Profile
@ReticulatedSpline
ReticulatedSpline / linear_regression.py
Last active February 5, 2020 05:33
Return coeffecients from linreg algorithm
# Created for UMD Spring Math 3810 | Professor Trogdon | Benjamin Carpenter
def lin_reg(X, Y):
"""Given an X and Y, return optimal coefficients"""
if len(X) != len(Y):
return -1
mean_x = np.mean(X)
mean_y = np.mean(Y)
numerator = 0
denominator = 0
for i in range(len(X)):