title: “Untitled” author: “姬小闲” date: “2025-11-25” output: html_document: df_print: paged
months <- c(1:60)
sizes <- c(10, 14, 47, 50, 60, 91, 118, 166, 119, 123, 109, 160, 168,
216,240, 232, 276, 331, 346, 348, 369, 405, 399, 410, 460, 400, 432,
458, 460, 478, 472, 510, 510, 523, 594, 565, 634, 631, 671, 744, 782,
786,773,784,842,888,927, 898, 949, 979, 994, 1025,1003,962, 968, 991,
982,959,973,974)
plot(months, sizes, type=“o”, col=“blue”, xlab=“Month”, ylab=“Size”, main=“Bird Population Size Over Time”)
increments <- diff(sizes)
hist(increments, breaks=10, main=“Histogram of Increments”, xlab=“Increment”, col=“lightgreen”, border=“black”)
shapiro_test_result <- shapiro.test(increments) cat(“Shapiro-Wilk Test for Normality on Increments:”) print(shapiro_test_result)
mu <- mean(increments) sigma <- sd(increments)
cat(“Estimated Drift (mu):”, mu, “”) cat(“Estimated Volatility (sigma):”, sigma, “”)
set.seed(12345) BM <- matrix(NA, nrow=500, ncol=4)
for (j in 1:4) { BM[1, j] <- 0
for (i in 2:500) { BM[i, j] <- mu * 0.01 + BM[i-1, j] + sigma *
sqrt(0.01) * rnorm(1)
} }
matplot(BM, type=“l”, lty=1, lwd=2, col=2:5, ylim=c(range(BM)), xlab=“Time”, ylab=“BM with Drift & Volatility”, panel.first=grid())
lines(months, sizes, col=“black”, lwd=2)