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 = '' > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. L. Weldon > #To cite this work: Weldon Larry, (2008), The Law of Averages (v1.0.2) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_rwalk.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: > 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/1awqv1228124276.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 > > system("convert tmp/1awqv1228124276.ps tmp/1awqv1228124276.png") > > > proc.time() user system elapsed 0.466 0.255 0.561