Created
January 14, 2021 21:22
-
-
Save ForteXX-2020/8017d7fc3941d8edd930b241f94f71ae to your computer and use it in GitHub Desktop.
0004_OLSregression
This file contains 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
from pylab import plt | |
import numpy as np | |
def f(x): | |
return 3 * x ** 3 - 4 * x ** 2 | |
x = np.linspace(-2, 4, 25) | |
y = f(x) | |
plt.figure(figsize=(10, 6)) | |
plt.plot(x, y, 'ro'); | |
a, b = np.polyfit(x, y, 1) | |
y_hat = a*x + b | |
plt.plot(x, y_hat, 'b-'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment