Created
May 21, 2016 13:09
-
-
Save af12066/caf8d85ca71fbfb5701e9de92c873990 to your computer and use it in GitHub Desktop.
Aの増加にともなうカオスのようすをみる.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(gganimate) # https://github.com/dgrtwo/gganimate | |
n.seq <- 1:(num/20) #ステップ数 | |
x.rep <- tail(n.seq, n = 1) #最大ステップ数 | |
A.seq <- seq(0.1, 4.0, 0.05) #Aを0.1から0.05刻みに増加させたときのようすを見る. | |
logistic <- function(A, x, n){ | |
npforeach(i = 1:n)({ | |
x <- A * x * (1 - x) | |
}) -> y | |
return(y) #ステップごとのxの値を出力させた. | |
} | |
npforeach(a = A.seq, .c = rbind)({ | |
x <- logistic(a, 0.01, x.rep) | |
data.frame(A=a, x=x, n=n.seq) | |
}) -> y2 | |
g2 <- ggplot(y2, aes(n, x, frame = A)) + geom_line(size = 0.3) | |
gg_animate(g2, interval = .5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment