统计分析:使用 R 的简介/前言
外观
library(caTools) # 提供 write.gif 函数的外部软件包 jet.colors <- colorRampPalette(c("#00007F", "blue", "#007FFF", "cyan", "#7FFF7F",
"yellow", "#FF7F00", "red", "#7F0000"))
m <- 1200 # 定义大小 C <- complex( real=rep(seq(-1.8,0.6, length.out=m), each=m ),
imag=rep(seq(-1.2,1.2, length.out=m), m ) )
C <- matrix(C,m,m) # 重整为复数矩阵 Z <- 0 # 初始化 Z 为零 X <- array(0, c(m,m,20)) # 初始化输出 3D 数组 for (k in 1:20) { # 循环 20 次
Z <- Z^2+C # the central difference equation X[,,k] <- exp(-abs(Z)) # capture results
} write.gif(X, "Mandelbrot.gif", col=jet.colors, delay=100)