library(ggplot2)
library(tidyr)
r0 <- 0.2
a <- 0.01
P0 <- 10
N <- 100
P <- numeric(N + 1)
P[1] <- P0
for (n in 1:N) {
P[n + 1] <- (1 + r0) * P[n] - a * P[n]^2
}
data <- data.frame(Time = 0:N, Population = P)
ggplot(data, aes(x = Time, y = Population)) +
geom_line() +
ggtitle("Scenario 1: Stable Equilibrium") +
xlab("Time") + ylab("Population") +
theme_minimal()Day7Prep
r0 <- 1.0
a <- 0.02
P0 <- 5
P <- numeric(N + 1)
P[1] <- P0
for (n in 1:N) {
P[n + 1] <- (1 + r0) * P[n] - a * P[n]^2
}
data <- data.frame(Time = 0:N, Population = P)
ggplot(data, aes(x = Time, y = Population)) +
geom_line() +
ggtitle("Scenario 2: Oscillatory Behavior") +
xlab("Time") + ylab("Population") +
theme_minimal()r0 <- 2.0
a <- 0.04
P0 <- 5
P <- numeric(N + 1)
P[1] <- P0
for (n in 1:N) {
P[n + 1] <- (1 + r0) * P[n] - a * P[n]^2
}
data <- data.frame(Time = 0:N, Population = P)
ggplot(data, aes(x = Time, y = Population)) +
geom_line() +
ggtitle("Scenario 3: Chaotic Dynamics") +
xlab("Time") + ylab("Population") +
theme_minimal()