R version 2.8.0 (2008-10-20) Copyright (C) 2008 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > par20 = '' > par19 = '' > par18 = '' > par17 = '' > par16 = '' > par15 = '' > par14 = '' > par13 = '' > par12 = '' > par11 = '' > par10 = '' > par9 = '' > par8 = '' > par7 = '' > par6 = '' > par5 = '' > par4 = '' > par3 = '' > par2 = '0.5' > par1 = '500' > ylab = '' > xlab = '' > main = '' > n <- as.numeric(par1) > p <- as.numeric(par2) > heads=rbinom(n-1,1,p) > a=2*(heads)-1 > b=diffinv(a,xi=0) > c=1:n > pheads=(diffinv(heads,xi=.5))/c > postscript(file="/var/www/html/rcomp/tmp/1j19e1228160646.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > op=par(mfrow=c(2,1)) > plot(c,b,type='n',main='Law of Averages',xlab='Toss Number',ylab='Excess of Heads',lwd=2,cex.lab=1.5,cex.main=2) > lines(c,b,col='red') > lines(c,rep(0,n),col='black') > plot(c,pheads,type='n',xlab='Toss Number',ylab='Proportion of Heads',lwd=2,cex.lab=1.5) > lines(c,pheads,col='blue') > lines(c,rep(.5,n),col='black') > par(op) > dev.off() null device 1 > b [1] 0 -1 -2 -1 0 -1 0 -1 -2 -3 -2 -1 -2 -1 -2 -3 -2 -3 [19] -2 -1 -2 -3 -4 -3 -4 -3 -2 -1 0 -1 0 -1 -2 -3 -2 -3 [37] -4 -5 -4 -3 -4 -5 -4 -3 -4 -3 -2 -1 0 1 2 1 2 3 [55] 2 3 2 3 2 1 2 1 0 -1 -2 -1 -2 -3 -4 -3 -2 -3 [73] -2 -3 -4 -5 -4 -5 -6 -7 -6 -5 -4 -5 -6 -7 -6 -7 -6 -7 [91] -8 -9 -10 -9 -8 -9 -10 -11 -12 -11 -12 -13 -12 -13 -12 -13 -12 -11 [109] -12 -13 -14 -15 -14 -15 -16 -15 -14 -13 -12 -11 -10 -11 -12 -13 -12 -11 [127] -12 -13 -14 -15 -16 -17 -16 -17 -16 -17 -18 -19 -18 -17 -16 -17 -18 -19 [145] -18 -19 -18 -17 -16 -15 -14 -15 -14 -13 -12 -11 -12 -13 -12 -11 -12 -11 [163] -12 -11 -10 -9 -10 -9 -8 -9 -8 -7 -6 -7 -6 -5 -4 -3 -2 -1 [181] -2 -3 -2 -3 -2 -3 -2 -3 -4 -5 -4 -3 -4 -3 -4 -5 -6 -5 [199] -6 -7 -6 -5 -6 -5 -4 -5 -4 -3 -2 -3 -4 -3 -2 -1 0 -1 [217] 0 -1 0 1 2 1 2 1 2 3 2 1 2 3 2 3 2 1 [235] 0 -1 0 1 0 -1 -2 -3 -4 -5 -4 -5 -4 -3 -2 -3 -2 -1 [253] 0 -1 -2 -1 0 1 2 1 0 1 2 1 2 3 2 3 4 3 [271] 2 3 4 5 4 5 4 3 4 5 6 7 8 9 8 7 8 9 [289] 8 7 8 9 8 9 8 7 6 7 6 5 6 7 6 7 8 9 [307] 8 7 8 7 6 5 4 3 4 5 6 5 4 5 6 5 4 3 [325] 4 5 4 3 4 5 6 7 8 9 10 9 10 11 12 11 12 13 [343] 14 13 14 13 12 13 14 13 14 15 14 13 14 13 14 13 12 11 [361] 12 13 14 15 16 15 16 15 14 13 14 15 16 17 18 17 18 17 [379] 16 17 16 15 16 15 16 17 16 17 16 15 16 17 18 19 20 19 [397] 20 21 22 23 22 21 22 21 20 21 20 19 20 19 18 19 20 19 [415] 20 21 22 21 20 21 20 19 18 19 18 17 18 19 20 21 22 23 [433] 24 25 26 25 24 25 26 27 28 29 28 27 28 29 30 31 32 31 [451] 32 31 32 33 34 33 34 33 34 35 34 33 34 33 32 31 30 31 [469] 30 31 30 29 30 31 30 29 30 29 30 29 28 29 28 27 26 25 [487] 26 25 26 27 26 27 26 25 24 23 22 21 22 23 > postscript(file="/var/www/html/rcomp/tmp/2it6q1228160646.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > racf <- acf(b,n/10,main='Autocorrelation',xlab='lags',ylab='ACF') > dev.off() null device 1 > racf Autocorrelations of series 'b', by lag 0 1 2 3 4 5 6 7 8 9 10 11 12 1.000 0.995 0.991 0.987 0.982 0.977 0.972 0.967 0.961 0.955 0.949 0.943 0.937 13 14 15 16 17 18 19 20 21 22 23 24 25 0.931 0.925 0.918 0.911 0.905 0.898 0.891 0.884 0.878 0.871 0.864 0.856 0.849 26 27 28 29 30 31 32 33 34 35 36 37 38 0.842 0.835 0.828 0.822 0.815 0.808 0.802 0.794 0.787 0.780 0.773 0.765 0.756 39 40 41 42 43 44 45 46 47 48 49 50 0.749 0.741 0.733 0.726 0.718 0.711 0.703 0.696 0.688 0.681 0.674 0.667 > > system("convert tmp/1j19e1228160646.ps tmp/1j19e1228160646.png") > system("convert tmp/2it6q1228160646.ps tmp/2it6q1228160646.png") > > > proc.time() user system elapsed 0.625 0.391 1.767