I did the usual sum method with the populations and divided by the timescale number to get the average, but the numbers always end up being a bit too high.
For example, if timescale is 10, then the years are 0-10 inclusive. Including year 0 and year 10, that's really 11 years and you would divide by 11. Generalize from there.
I think the problem is when it's calculating the sum, but I am not sure when it happens in the code.
I was able to fix it!