R version 2.9.0 (2009-04-17) Copyright (C) 2009 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. > par8 = '' > par7 = '' > par6 = '0' > par5 = 'Y' > par4 = '2' > par3 = '1' > par2 = '.5' > par1 = '100' > ylab = 'density' > xlab = 'value of generated random numbers' > main = 'Histogram of Generated Random Numbers' > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: Write here your technical program description (don't use hard returns!) > library(MASS) > library(msm) > par1 <- as.numeric(par1) > if (par1 > 10000) par1=10000 #impose restriction on number of random values > par2 <- as.numeric(par2) > par3 <- as.numeric(par3) > par4 <- as.numeric(par4) > if (par6 == '0') par6 = 'Sturges' else { + par6 <- as.numeric(par6) + if (par6 > 50) par6 = 50 #impose restriction on the number of bins + } > if (par7 == '') par7 <- -Inf else par7 <- as.numeric(par7) > if (par8 == '') par8 <- Inf else par8 <- as.numeric(par8) > x <- rtnorm(par1,par2,par3,par7,par8) > x <- as.ts(x) #otherwise the fitdistr function does not work properly > if ((par7 == -Inf) & (par8 == Inf)) (r <- fitdistr(x,'normal')) mean sd 0.49361982 1.02917672 (0.10291767) (0.07277378) > postscript(file="/var/www/html/rcomp/tmp/1lsn21259075460.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > myhist<-hist(x,col=par4,breaks=par6,main=main,ylab=ylab,xlab=xlab,freq=F) > if ((par7 == -Inf) & (par8 == Inf)) { + curve(1/(r$estimate[2]*sqrt(2*pi))*exp(-1/2*((x-r$estimate[1])/r$estimate[2])^2),min(x),max(x),add=T) + } > dev.off() null device 1 > > #Note: the /var/www/html/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/rcomp/createtable") > > if (par5 == 'Y') + { + a<-table.start() + a<-table.row.start(a) + a<-table.element(a,'Index',1,TRUE) + a<-table.element(a,'Value',1,TRUE) + a<-table.row.end(a) + for (i in 1:par1) + { + a<-table.row.start(a) + a<-table.element(a,i,header=TRUE) + a<-table.element(a,x[i]) + a<-table.row.end(a) + } + a<-table.end(a) + table.save(a,file="/var/www/html/rcomp/tmp/28dk91259075460.tab") + } > if ((par7 == -Inf) & (par8 == Inf)) { + a<-table.start() + a<-table.row.start(a) + a<-table.element(a,'Parameter',1,TRUE) + a<-table.element(a,'Value',1,TRUE) + a<-table.element(a,'Standard Deviation',1,TRUE) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'# simulated values',header=TRUE) + a<-table.element(a,par1) + a<-table.element(a,'-') + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'true mean',header=TRUE) + a<-table.element(a,par2) + a<-table.element(a,'-') + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'true standard deviation',header=TRUE) + a<-table.element(a,par3) + a<-table.element(a,'-') + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'mean',header=TRUE) + a<-table.element(a,r$estimate[1]) + a<-table.element(a,r$sd[1]) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'standard deviation',header=TRUE) + a<-table.element(a,r$estimate[2]) + a<-table.element(a,r$sd[2]) + a<-table.row.end(a) + a<-table.end(a) + table.save(a,file="/var/www/html/rcomp/tmp/3jxpx1259075460.tab") + } > > system("convert tmp/1lsn21259075460.ps tmp/1lsn21259075460.png") > > > proc.time() user system elapsed 0.508 0.186 0.955