R version 3.6.3 (2020-02-29) -- "Holding the Windsock" Copyright (C) 2020 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) 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. > source('/home/pw/wessanet/cretab') > > > > myrfcuid = '' > > par8 = '100' > par7 = '50' > par6 = '0' > par5 = 'N' > par4 = '2' > par3 = '10' > par2 = '75' > par1 = '100' > ylab = 'density' > xlab = 'value of generated random numbers' > main = 'Histogram of Generated Random Numbers' > par8 <- '100' > par7 <- '50' > par6 <- '0' > par5 <- 'N' > par4 <- '2' > par3 <- '10' > par2 <- '75' > par1 <- '100' > #'GNU S' R Code compiled by R2WASP v. 1.2.327 (Fri, 07 Oct 2016 08:05:16 +0200) > #Author: root > #To cite this work: Wessa P., (2016), Random Number Generator for the Normal Distribution (v1.0.11) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_rngnorm.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > # > library(MASS) > library(msm) > par1 <- sub(',','.',par1) > par2 <- sub(',','.',par2) > par3 <- sub(',','.',par3) > par4 <- sub(',','.',par4) > 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')) > postscript(file="/home/pw/wessanet/rcomp/tmp/1z6dc1586478071.ps",horizontal=F,onefile=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 > > 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="/home/pw/wessanet/rcomp/tmp/2j9w41586478071.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="/home/pw/wessanet/rcomp/tmp/3878d1586478071.tab") + } > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Frequency Table (Histogram)',6,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Bins',header=TRUE) > a<-table.element(a,'Midpoint',header=TRUE) > a<-table.element(a,'Abs. Frequency',header=TRUE) > a<-table.element(a,'Rel. Frequency',header=TRUE) > a<-table.element(a,'Cumul. Rel. Freq.',header=TRUE) > a<-table.element(a,'Density',header=TRUE) > a<-table.row.end(a) > crf <- 0 > mynumrows <- (length(myhist$breaks)-1) > for (i in 1:mynumrows) { + a<-table.row.start(a) + dum <- paste('[',myhist$breaks[i],sep='') + dum <- paste(dum,myhist$breaks[i+1],sep=',') + if (i==mynumrows) + dum <- paste(dum,']',sep='') + else + dum <- paste(dum,'[',sep='') + a<-table.element(a,dum,header=TRUE) + a<-table.element(a,myhist$mids[i]) + a<-table.element(a,myhist$counts[i]) + rf <- myhist$counts[i]/par1 + crf <- crf + rf + a<-table.element(a,round(rf,6)) + a<-table.element(a,round(crf,6)) + a<-table.element(a,round(myhist$density[i],6)) + a<-table.row.end(a) + } > a<-table.end(a) > table.save(a,file="/home/pw/wessanet/rcomp/tmp/4yhvt1586478071.tab") > > try(system("convert /home/pw/wessanet/rcomp/tmp/1z6dc1586478071.ps /home/pw/wessanet/rcomp/tmp/1z6dc1586478071.png",intern=TRUE)) character(0) > > proc.time() user system elapsed 0.935 0.104 1.077