一直不知道怎么画递推公式的曲线,于是只好先将数值挨个都计算出来。
这是生态学中的一个种群生长模型:X(次年)=Gamma*X*(1-X)。
用R把这个方程的曲线簇给画出来玩玩,不同颜色代表了Gamma在不同取值范围内引起的曲线的混沌变化:
<br />
draw_chaos <- function (generation, gamma_from=.1, gamma_to=4, gamma_by=.05) {<br />
gamma <- seq(from = gamma_from, to = gamma_to, by = gamma_by);<br />
x <- matrix(.1, length(gamma), 1);<br />
replicate(generation, x <<- cbind(x, gamma * x[,dim(x)[2]] * (1 - x[,dim(x)[2]])));<br />
plot(c(1,generation), c(0,1), type='n');<br />
color_list <- c("yellow", "green", "red", "black");<br />
cut_gamma <- c(min(gamma),1,2.7,3,max(gamma));<br />
for (i in dim(x)[1]:1) {<br />
lines(x[i,], col = color_list[cut(gamma[i], cut_gamma)]);<br />
}<br />
}<br />
draw_chaos(30)<br />