# ::Free Statistics and Forecasting Software::

v1.1.23-r7
Secure website (SSL) | Donate to wessa.net

### :: Random Number Generator - Normal Distribution - Free Statistics Software (Calculator) ::

All rights reserved. The non-commercial (academic) use of this software is free of charge. The only thing that is asked in return is to cite this software when results are used in publications.

This free online software (calculator) generates random numbers for the Normal distribution. The parameters allow you to specify the length of the dataseries to be generated, the mean of the distribution, and the standard error of the distribution.

The generated random numbers are listed in a table and the corresponding histogram is shown in a chart.

 Send output to: Browser Blue - Charts White Browser Black/White CSV MS Excel MS Word Number of values (?) Mean (?) S.D. (?) Color code (?) 23456781 List Random Numbers in table? (?) NY Number of bins (?) Lower truncation point (leave blank for -infinity) Upper truncation point (leave blank for +infinity) Chart options Width: Height: Title: Label y-axis: Label x-axis:

Click here to edit the underlying code of this R Module.

 Source code of R module 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")) bitmap(file="test1.png") 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() load(file="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="mytable1.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="mytable.tab") }
 Top | Output | Charts | References | History | Feedback

 Cite this software as: Wessa P., (2008), Random Number Generator for the Normal Distribution (v1.0.8) in Free Statistics Software (v1.1.23-r7), Office for Research Development and Education, URL http://www.wessa.net/rwasp_rngnorm.wasp/ The R code is based on : Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988), The New S Language, Wadsworth & Brooks/Cole. Wichura, M. J. (1988) Algorithm AS 241: The Percentage Points of the Normal Distribution, Applied Statistics, nr. 37, 477-484.
 Top | Output | Charts | References | History | Feedback
 Top | Output | Charts | References | History | Feedback