Skip to content

Instantly share code, notes, and snippets.

@juanplopes
Last active March 22, 2020 16:02
Show Gist options
  • Save juanplopes/21296148c05000c4f24e7b445fd37803 to your computer and use it in GitHub Desktop.
Save juanplopes/21296148c05000c4f24e7b445fd37803 to your computer and use it in GitHub Desktop.
import datetime, numpy as np
first_day = datetime.date(2020, 2, 26)
y = np.array([1, 1, 1, 2, 2, 2, 2, 4, 4, 13, 13, 20, 25, 31, 38, 52, 151, 151, 162, 200, 321, 372, 621, 793])
x = np.arange(1, len(y)+1)
curve = np.exp(np.polyfit(x, np.log(y), 1))
#y = b*a^x
#log(y) = xlog(a)+log(b)
print('Crescimento por dia: %.2f%%' % (curve[0]*100-100))
for i in range(65):
print('%s\t%d\t%s' % (
first_day + datetime.timedelta(days = i),
curve[1] * curve[0]**(i+1),
y[i] if i < len(y) else ''
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment