diff options
Diffstat (limited to 'test.py')
-rw-r--r-- | test.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test.py b/test.py new file mode 100644 index 0000000..d0f93c4 --- /dev/null +++ b/test.py @@ -0,0 +1,15 @@ +import numpy as np +import matplotlib.pyplot as plt + +x = [1,2,3,4] +y = [3,5,7,10] # 10, not 9, so the fit isn't perfect + +fit = np.polyfit(x,y,1) +fit_fn = np.poly1d(fit) +# fit_fn is now a function which takes in x and returns an estimate for y + +plt.plot(x,y, 'yo', x, fit_fn(x), '--k') +plt.xlim(0, 5) +plt.ylim(0, 12) + +plt.show() |