Created
April 13, 2019 02:07
-
-
Save paultopia/e47193bc335a7dfb630bbc6a894c26fa to your computer and use it in GitHub Desktop.
simple_regression.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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