Download the R script run_logistic.R and execute it in an R command shell. (One way to execute the file is to enter source("run_logistic.R") when you are in the directory where you saved the file.) Once you have run the script file, it will have defined the function run_logistic, which will simulate the above logistic model.
To check if it worked, simulate the logistic model with parameters $r=0.1$ and $K=5000$. Simulate it starting with many different initial conditions $p_0 \ge 0$, including some smaller and larger than $5000$. For example, to simulate it with initial condition $p_0=100$, run the commands
results = run_logistic(r=0.1, K=5000, p0=100)
plot(results)
which save the results to the variable results and then plot a graph of the population size versus time. (See comments at beginning of script for more details on how to run it as well as how to look at the output results.)
You should find that for most initial conditions $p_0 \ge 0$, the population size approaches the same value for large $t$. (Depending on the initial condition you choose, you may need to increase tmax beyond 100 to see the value, for example, by adding tmax=400 to your call of run_logistic.)
Summarize your results.
As long as $p_0 >$
, the population size approaches
.
If we start with $p_0=$
, then the population size stays at
.
The latter result makes sense because
.
The former result, though, might make you wonder. If you start with a population that contains one-tenth of one elk, i.e., with $p_0=0.1$, what does the logistic model predict should happen to the elk population?
(Although we might be uncomfortable with the results when starting with $p_0=0.1$, in general, don't worry about having fractions of elks, such as 102.3 elk. Allowing fractional population sizes just makes the math easier.)