From eba7c6428aebe1827d0858577ce2e52f06f7ba7b Mon Sep 17 00:00:00 2001 From: zhang Date: Sat, 16 Nov 2019 09:56:55 +0800 Subject: double 11 --- double_11.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 double_11.py (limited to 'double_11.py') 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 -- cgit v1.2.3