Skip to content

Instantly share code, notes, and snippets.

@juanplopes

juanplopes/regression.py

Last active Mar 22, 2020
Embed
What would you like to do?
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
You can’t perform that action at this time.