Learn R Programming

qualityTools (version 1.55)

lnorm3: The Lognormal Distribution (3 Parameter)

Description

Density function, distribution function and quantile function for the Lognormal distribution.

Usage

dlnorm3(x, meanlog, sdlog, threshold) plnorm3(q, meanlog, sdlog, threshold) qlnorm3(p, meanlog, sdlog, threshold, ...)

Arguments

x, q
vector of quantiles
p
vector of probabilities
meanlog, sdlog
mean and standard deviation of the distribution on the log scale with default values of ‘0’ and ‘1’ respectively.
threshold
threshold parameter by default 0
...
Arguments that can be passed into uniroot.

Value

dlnorm3 gives the density, plnorm3 gives the distribution function and qlnorm3 gives the quantile function.

Details

The Lognorm distribution with ‘meanlog’ parameter zeta, ‘meansd’ parameter sigma and ‘threshold’ parameter theta has density given by

f(x) = (1/(sqrt(2*pi)*sigma*(x-theta))) *exp(-(((log((x-theta))-zeta)^2)/(2*(sigma)^2))) The cumulative distribution function is given by F(x) = pnorm((log((x-theta))-zeta)/sigma)

References

Johnson, L., Kotz, S., Balakrishnan, N. (1995) Continuous Univariate Distributions-Volume 1, 2nd ed. New York: John Wiley & Sons.

See Also

uniroot

Examples

Run this code
#Simple Example
dlnorm3(x=2,meanlog=0,sdlog=1/8,threshold=1)
temp=plnorm3(q=2,meanlog=0,sdlog=1/8,threshold=1)
temp
qlnorm3(p=temp,meanlog=0,sdlog=1/8,threshold=1)
#
##Visualized Example
##prepare screen
#dev.new()
#split.screen(matrix(c(0,0.5,0,1, 0.5,1,0,1),byrow=TRUE,ncol=4))
##generate values 
#x=seq(0,4,length=1000)
##plot different density functions
#screen(1)                                                                              
#plot(x,y=dlnorm3(x,0,1/8,1),col="green",xlim=c(0,3),type="l",lwd=2,xlab="x",
#     ylab="f(x)",main="Density Function of Log-Normal-Distribution")
#lines(x,y=dlnorm3(x,0,0.5,0),lwd=2,col="red")
#lines(x,y=dlnorm3(x,0,1,0),lwd=2,col="blue")
#lines(x,y=dlnorm3(x,1,1/8,0),lwd=2,col="orange")
##add legend
#legend("topleft",legend=c(expression(paste(zeta," = 0 ")*
#       paste(sigma, " = 1/8 ")*paste(theta," = 1")),
#       expression(paste(zeta," = 0 ")*paste(sigma, " = 0.5 ")*
#       paste(theta," = 0")),expression(paste(zeta," = 0 ")*
#       paste(sigma, " = 1 ")*paste(theta," = 0")),
#       expression(paste(zeta," = 1 ")*paste(sigma, " = 1/8 ")*
#       paste(theta," = 0"))),col=c("green","red","blue","orange"),
#       text.col="black",lwd=2,bty="o",inset=0.04)
#abline(v=0,lty=2,col="grey")
#abline(h=0,lty=2,col="grey")
##plot different distribution functions
#screen(2)
#plot(x,y=plnorm3(x,0,1/8,1),col="green",xlim=c(0,3),type="l",lwd=2,xlab="x",
#     ylab="F(x)",
#     main="Cumulative Distribution Function of Log-Normal-Distribution")
#lines(x,y=plnorm3(x,0,0.5,0),lwd=2,col="red")
#lines(x,y=plnorm3(x,0,1,0),lwd=2,col="blue")
#lines(x,y=plnorm3(x,1,1/8,0),lwd=2,col="orange")
##add legend
#legend("topleft",legend=c(expression(paste(zeta," = 0 ")*
#       paste(sigma, " = 1/8 ")*paste(theta," = 1")),
#       expression(paste(zeta," = 0 ")*paste(sigma, " = 0.5 ")*
#       paste(theta," = 0")),expression(paste(zeta," = 0 ")*
#       paste(sigma, " = 1 ")*paste(theta," = 0")),
#       expression(paste(zeta," = 1 ")*paste(sigma, " = 1/8 ")*
#       paste(theta," = 0"))),col=c("green","red","blue","orange"),
#       text.col="black",lwd=2,bty="o",inset=0.04)
#abline(v=0,lty=2,col="grey")
#abline(h=0,lty=2,col="grey")
#close.screen(all=TRUE)

Run the code above in your browser using DataLab