Skip to content

Instantly share code, notes, and snippets.

@paultopia
Created April 13, 2019 02:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paultopia/e47193bc335a7dfb630bbc6a894c26fa to your computer and use it in GitHub Desktop.
Save paultopia/e47193bc335a7dfb630bbc6a894c26fa to your computer and use it in GitHub Desktop.
simple_regression.py
import numpy as np
def beta(x, y):
mean_x = np.mean(x)
mean_y = np.mean(y)
numerator = 0
for pair in zip(x, y):
numerator += (pair[0] - mean_x) * (pair[1] - mean_y)
denominator = np.sum([np.square(item - mean_x) for item in x])
return numerator / denominator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment