Wednesday, April 11, 2007

Logistic RUN again!


Just now I finished drawing another Logistic equation plot, using incremental factor starting from -2.

Following is R code to perform the drawing, includes the 2 pics before:

iterate = 300
Rinit = -2
Rrun = Rinit
Rarr = numeric(iterate)

step = 0.02

testrun = 100

arr = array(0,dim=c(iterate,testrun))
arr[,1] = 0.1


for(i in 1:iterate){
for(j in 2:testrun){
arr[i,j] = Rrun * arr[i,j-1] * (1-arr[i,j-1])
}
Rarr[i] = (arr[i,j]+arr[i,j-1])/2
Rrun = Rinit + step*i
}
matplot(seq(from=Rinit,by=step,length.out=iterate),arr,type="l")

No comments: