::Free Statistics and Forecasting Software::

v1.1.20
 
 

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

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 a specified number of random series for the Log-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 (if possible). In addition a histogram is shown of the estimated mean and standard deviation (over all simulated series)

This R module is an illustration of the central limit theorem.

Send output to:
Number of values (?)
Mean (?)
S.D. (?)
Color code (?)
List Random Numbers in table? (?)
Number of bins (?)
Number of series (?)
Chart options
Width:
Height:


Cite this software as:
Wessa P., (2006), Random Number Generator for the Log-Normal Distribution (v1.0.3) in Free Statistics Software (v1.1.20), Office for Research Development and Education, URL http://www.wessa.net/rwasp_rnglnorm.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.
Source code of R module
1library(MASS)
2par1 <- as.numeric(par1)
3par2 <- as.numeric(par2)
4par2 <- round(par2,2) #rounded (we want to be able to display 10 columns)
5par3 <- as.numeric(par3)
6par3 <- round(par3,2) #rounded (we want to be able to display 10 columns)
7par4 <- as.numeric(par4)
8if (par6 == "0") par6 = "Sturges" else par6 <- as.numeric(par6)
9par7 <- as.numeric(par7)
10x <- array(NA,dim=c(par7,par1))
11rest.mean <- array(NA,dim=c(par7))
12rest.sd <- array(NA,dim=c(par7))
13rsd.mean <- array(NA,dim=c(par7))
14rsd.sd <- array(NA,dim=c(par7))
15for (i in 1:par7)
16{
17x[i,] <- rlnorm(par1,par2,par3)
18x[i,] <- as.ts(x[i,]) #otherwise the fitdistr function does not work properly
19dum <- fitdistr(x[i,],"log-normal")
20rest.mean[i] <- dum$estimate[1]
21rest.sd[i] <- dum$estimate[2]
22rsd.mean[i] <- dum$sd[1]
23rsd.sd[i] <- dum$sd[2]
24}
25nc <- par7
26if (nc > 10) nc = 10
27if (par5 == "Y")
28{
29load(file="createtable")
30a<-table.start()
31a<-table.row.start(a)
32a<-table.element(a,"Index",1,TRUE)
33for (j in 1:nc)
34{
35a<-table.element(a,paste("X",j),1,TRUE)
36}
37a<-table.row.end(a)
38if (nc < par7)
39{
40a<-table.row.start(a)
41a<-table.element(a,"Note: only the first 10 series are displayed",nc+1,TRUE)
42a<-table.row.end(a)
43}
44for (i in 1:par1)
45{
46a<-table.row.start(a)
47a<-table.element(a,i,header=TRUE)
48for (j in 1:nc)
49{
50a<-table.element(a,round(x[j,i],2))
51}
52a<-table.row.end(a)
53}
54a<-table.end(a)
55table.save(a,file="mytable1.tab")
56}
57load(file="createtable")
58a<-table.start()
59a<-table.row.start(a)
60a<-table.element(a,"Parameter",1,TRUE)
61for (j in 1:nc)
62{
63a<-table.element(a,paste("X",j,sep=""),1,TRUE)
64}
65a<-table.row.end(a)
66a<-table.row.start(a)
67a<-table.element(a," ",1,TRUE)
68for (j in 1:nc)
69{
70a<-table.element(a,"(SD)",1,TRUE)
71}
72a<-table.row.end(a)
73a<-table.row.start(a)
74a<-table.element(a,"# simulated values",header=TRUE)
75for (j in 1:nc)
76{
77a<-table.element(a,par1)
78}
79a<-table.row.end(a)
80a<-table.row.start(a)
81a<-table.element(a,"true mean",header=TRUE)
82for (j in 1:nc)
83{
84a<-table.element(a,par2)
85}
86a<-table.row.end(a)
87a<-table.row.start(a)
88a<-table.element(a,"true standard deviation",header=TRUE)
89for (j in 1:nc)
90{
91a<-table.element(a,par3)
92}
93a<-table.row.end(a)
94a<-table.row.start(a)
95a<-table.element(a,"mean",header=TRUE)
96for (j in 1:nc)
97{
98a<-table.element(a,round(rest.mean[j],2))
99}
100a<-table.row.end(a)
101a<-table.row.start(a)
102a<-table.element(a," ",header=TRUE)
103for (j in 1:nc)
104{
105a<-table.element(a,round(rsd.mean[j],2))
106}
107a<-table.row.end(a)
108a<-table.row.start(a)
109a<-table.element(a,"standard deviation",header=TRUE)
110for (j in 1:nc)
111{
112a<-table.element(a,round(rest.sd[j],2))
113}
114a<-table.row.end(a)
115a<-table.row.start(a)
116a<-table.element(a," ",header=TRUE)
117for (j in 1:nc)
118{
119a<-table.element(a,round(rsd.sd[j],2))
120}
121a<-table.row.end(a)
122a<-table.end(a)
123table.save(a,file="mytable.tab")
124bitmap(file="test0.png")
125myhist<-hist(x[1,],col=par4,breaks=par6,main="Histogram of 1st simulated series",ylab="density",xlab="simulated values",freq=F)
126dev.off()
127bitmap(file="test1.png")
128myhist<-hist(rest.mean[],col=par4,breaks=par6,main="Histogram of Estimated Means",ylab="density",xlab="estimated means",freq=F)
129x <- rest.mean[]
130dummean <- mean(x)
131dumsd <- sd(x)
132curve(1/(dumsd*sqrt(2*pi))*exp(-1/2*((x-dummean)/dumsd)^2),min(x),max(x),add=T)
133dev.off()
134bitmap(file="test2.png")
135myhist<-hist(rest.sd[],col=par4,breaks=par6,main="Histogram of Estimated SDs",ylab="density",xlab="estimated standard deviations",freq=F)
136x <- rest.sd[]
137dummean <- mean(x)
138dumsd <- sd(x)
139curve(1/(dumsd*sqrt(2*pi))*exp(-1/2*((x-dummean)/dumsd)^2),min(x),max(x),add=T)
140dev.off()

To cite Wessa.net in publications use:
Wessa, P. (2009), Free Statistics Software, Office for Research Development and Education,
version 1.1.20, URL http://www.wessa.net/

© Resa R&D, and the 'Office for Research, Development, and Education' - All rights reserved. This website is an intellectual and physical property of Resa R&D. This includes: html content, graphical illustrations (gif files), computer software, online or electronic documentation, associated media, and printed materials. The free use of the scientific content, services, and applications in this website is granted for non commercial use only. In any case, the source (url) should always be clearly displayed. Under no circumstances are you allowed to reproduce, copy or redistribute the design, layout, or any content of this website (for commercial use) including any materials contained herein without the express written permission of Resa R&D or the Office for Research, Development, and Education.

Information provided on this web site is provided "AS IS" without warranty of any kind, either express or implied, including, without limitation, warranties of merchantability, fitness for a particular purpose, and noninfringement. We use reasonable efforts to include accurate and timely information and periodically update the information, and software without notice. However, Resa R&D makes no warranties or representations as to the accuracy or completeness of such information (or software), and it assumes no liability or responsibility for errors or omissions in the content of this web site, or any software bugs in online applications. Your use of this web site is AT YOUR OWN RISK. Under no circumstances and under no legal theory shall Resa R&D be liable to you or any other person for any direct, indirect, special, incidental, exemplary, or consequential damages arising from your access to, or use of, this web site.

Software Version : 1.1.20
Algorithms & Software : Prof. dr. P. Wessa
Facilities : Resa R&D - Office for Research, Development, and Education
Server : www.wessa.net

Comments, Feedback & Errors | Privacy Policy | Statistics Resources | Wessa.net Home

 © Wessa.Net 2002-2009  
 
 

Home Page
Equation Plotter
Time Series Analysis
Financial Databases
Multiple Regression
Descriptive Statistics
Statistical Distributions
Hypothesis Testing

Academic citations
Latest News
Archive (old versions)
FAQ
About Wessa.net

Black&White
Blue Theme

Google
Web wessa.net

All rights reserved. Academic license for non-commercial use only.

 
This website is kindly sponsored by:
Bandwidth Monitoring | Get a business or technology degree near you