I'm trying to plot a recursive function I had made that measures growth over time. Here is the function:
def pop(start_pop, years, percentage_change, max_pop):
if years == 0:
return start_pop
else:
changes = pop(start_pop,years-1,percentage_change,max_pop)
return changes + (1-changes/max_pop)*percentage_change*changes
print(pop(600,85,0.1,20000))
Which gives me the output of:
19879.4425
How can I plot this function of the graph, where "years" is on the x-axis and "max_pop" is on the y-axis?
Thanks for your help!
Note: If it helps, I'm wanting/ expecting once plotted that the curve will look something similar to a learning curve.
f(x, otherargs)at valuesx = [1,2,3,...]you evaluate the function on the list, e.g.y = [f(i, otherargs) for i in x]and plotplt.plot(x,y).