All problems
Logistic Growth Value
Problem
The logistic model has the closed-form solution y(t) = K / (1 + ((K - y0) / y0) * e^(-r*t)), where K is the carrying capacity and r the growth rate.
Given t, initial population y0 > 0, capacity k, and rate r, return y(t).
Hint
At t = 0 the exponential equals 1, so y = y0; large t drives y toward K.
Test cases
case 1
in: [0,10,100,1]
expected: 10
case 2
in: [10,100,100,1]
expected: 100
case 3
in: [1,10,100,1]
expected: 23.19693166840739
case 4
in: [5,50,100,0.5]
expected: 92.41418199787564
Starter codePython
def logistic_value(t, y0, k, r):
# Your code here
pass4 test cases · run your code against them in the editor