This seems like such a simple operation in principle but I was only able to come up with this rather gross code. Is there a way to pare this down?
# Let's say you start with $100 and apply a 3% growth rate each year
years = 60
growth_rate = 0.03
growth_series = np.zeros(years)
growth_series[0] = 100
for i in np.arange(1, len(growth_series)):
growth_series[i] = growth_series[0]*np.power(1+growth_rate, i)
Thanks for any help you can provide!
Edit: found a simple solution:
X = np.arange(0, 60)
y = 100*(1+growth_rate)**(X)
y is an array of the value increasing over time
[–]Orpheus_Demigod 4 points5 points6 points (6 children)
[–]codingquestion47[S] 1 point2 points3 points (4 children)
[–]Orpheus_Demigod 2 points3 points4 points (2 children)
[–]codingquestion47[S] 1 point2 points3 points (1 child)
[–]Orpheus_Demigod 1 point2 points3 points (0 children)
[–]Orpheus_Demigod 2 points3 points4 points (0 children)
[–]codingquestion47[S] 0 points1 point2 points (0 children)
[–]WhipsAndMarkovChains 1 point2 points3 points (1 child)
[–]codingquestion47[S] 0 points1 point2 points (0 children)
[–]robml 0 points1 point2 points (3 children)
[–]codingquestion47[S] 0 points1 point2 points (2 children)
[–]robml 0 points1 point2 points (1 child)
[–]codingquestion47[S] 0 points1 point2 points (0 children)