diff options
| author | zhang <zch921005@126.com> | 2019-11-16 09:56:55 +0800 |
|---|---|---|
| committer | zhang <zch921005@126.com> | 2019-11-16 09:56:55 +0800 |
| commit | eba7c6428aebe1827d0858577ce2e52f06f7ba7b (patch) | |
| tree | ee2215eb2126178b6ba09aedfc4353a98d6d7614 /double_11.py | |
| parent | 9aeaa9dc06b5ecd0d3c5f98b0bf80e8af0556e4b (diff) | |
double 11
Diffstat (limited to 'double_11.py')
| -rw-r--r-- | double_11.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/double_11.py b/double_11.py new file mode 100644 index 0000000..118cfb7 --- /dev/null +++ b/double_11.py @@ -0,0 +1,19 @@ + +import numpy as np +import matplotlib.pyplot as plt + +years = [y+2009 for y in range(11)] +gmvs = [0.5, 9.36, 52, 191, 350, 571, 912, 1207, 1682, 2135, 2684] + + +def polynomial(xs, ys, n): + f = np.polyfit(xs, ys, n) + def func(x): + return sum(f[i]*x**(n-i)for i in range(n+1)) + return func + +f = polynomial(years, gmvs, 3) +print(f(2020)) + +plt.plot(years, gmvs, marker='o') +plt.show()
\ No newline at end of file |
