# Linear Population Growth Model in R


# Starting population at week 0
init_population <- 50

# Rabbits added per week (These are k values)
k_values <- c(5, 15, 25)

# Time span: 0 to 12 weeks
weeks <- 0:12
# Build a table of population values for each number of weeks (5, 15, 25)

pop_data <- data.frame(week = weeks)

for (k in k_values) {
  pop_data[[paste0("growth ", k)]] <- init_population + (k * weeks)
}

print(pop_data)
##    week growth 5 growth 15 growth 25
## 1     0       50        50        50
## 2     1       55        65        75
## 3     2       60        80       100
## 4     3       65        95       125
## 5     4       70       110       150
## 6     5       75       125       175
## 7     6       80       140       200
## 8     7       85       155       225
## 9     8       90       170       250
## 10    9       95       185       275
## 11   10      100       200       300
## 12   11      105       215       325
## 13   12      110       230       350
# Plot population growth curves


# For k = 5
plot(weeks,
     init_population + k_values[1] * weeks,
     type = "l", col = "salmon", lwd = 2,
     ylim = c(50, max(init_population + k_values * max(weeks))),
     xlab = "Time (weeks)",
     ylab = "Population Growth N(t)",
     main = "Linear Population Growth (N0 = 50)")

# Add the other growth rate lines
lines(weeks, init_population + k_values[2] * weeks, col = "maroon", lwd = 2)
lines(weeks, init_population + k_values[3] * weeks, col = "gold", lwd = 2)

# Add a legend for clarity
legend("topleft",
       legend = c("k = 5 (slow growth)",
                  "k = 15 (moderate growth)",
                  "k = 25 (rapid growth)"),
       col = c("salmon", "maroon", "gold"),
       lty = 6, lwd = 9)

#   Notes:


# - 'k' controls the slope of the line.

# - Larger k = faster growth (steeper line).



# k = 5  → slow growth, 110 rabbits at 12 weeks.

# k = 15 → moderate growth, 230 rabbits at 12 weeks.

# k = 25 → rapid growth, 350 rabbits at 12 weeks.

#  
# C

# The linear model says the population grows by the same fixed amount each time period. It doesn’t matter how big the population already is — growth is steady and predictable. This makes sense for short time spans or in situations where growth is tightly managed, so natural ups and downs don’t really matter.


# A company adds 100 new subscribers every week through a marketing campaign. No matter how many subscribers it already has, the growth is steady. 100 more each week. The subscriber base grows in a straight line.