Main Content

Lognormal Distribution

Overview

The lognormal distribution, sometimes called the Galton distribution, is a probability distribution whose logarithm has a normal distribution. The lognormal distribution is applicable when the quantity of interest must be positive, because log(x) exists only whenxis positive.

Statistics and Machine Learning Toolbox™ offers several ways to work with the lognormal distribution.

  • Create a probability distribution objectLognormalDistributionby fitting a probability distribution to sample data (fitdist) or by specifying parameter values (makedist). Then, use object functions to evaluate the distribution, generate random numbers, and so on.

  • Work with the lognormal distribution interactively by using theDistribution Fitterapp. You can export an object from the app and use the object functions.

  • Use distribution-specific functions (logncdf,lognpdf,logninv,lognlike,lognstat,lognfit,lognrnd) with specified distribution parameters. The distribution-specific functions can accept parameters of multiple lognormal distributions.

  • Use generic distribution functions (cdf,icdf,pdf,random) with a specified distribution name ('Lognormal') and parameters.

Parameters

The lognormal distribution uses these parameters.

Parameter Description 金宝app
mu(μ) Mean of logarithmic values < μ <
sigma(σ) Standard deviation of logarithmic values σ 0

IfXfollows the lognormal distribution with parametersµandσ, then log(X) follows the normal distribution with meanµand standard deviationσ.

Parameter Estimation

To fit the lognormal distribution to data and find the parameter estimates, uselognfit,fitdist, ormle.

  • For uncensored data,lognfitandfitdistfind the unbiased estimates of the distribution parameters, andmlefinds the maximum likelihood estimates.

  • 对于审查数据,lognfit,fitdist, andmlefind the maximum likelihood estimates.

Unlikelognfitandmle, which return parameter estimates,fitdistreturns the fitted probability distribution objectLognormalDistribution. The object propertiesmuandsigmastore the parameter estimates.

Descriptive Statistics

The meanmand variancevof a lognormal random variable are functions of the lognormal distribution parametersµandσ:

m = exp ( μ + σ 2 / 2 ) v = exp ( 2 μ + σ 2 ) ( exp ( σ 2 ) 1 )

Also, you can compute the lognormal distribution parametersµandσfrom the meanmand variancev:

μ = log ( m 2 / v + m 2 ) σ = log ( v / m 2 + 1 )

Probability Density Function

The probability density function (pdf) of the lognormal distribution is

y = f ( x | μ , σ ) = 1 x σ 2 π exp { ( log x μ ) 2 2 σ 2 } , for x > 0.

For an example, seeCompute Lognormal Distribution pdf.

Cumulative Distribution Function

The cumulative distribution function (cdf) of the lognormal distribution is

p = F ( x | μ , σ ) = 1 σ 2 π 0 x 1 t exp { ( log t μ ) 2 2 σ 2 } d t , for x > 0.

For an example, seeCompute Lognormal Distribution cdf.

Examples

Compute Lognormal Distribution pdf

Suppose the income of a family of four in the United States follows a lognormal distribution withmu = log(20,000)andsigma = 1. Compute and plot the income density.

Create a lognormal distribution object by specifying the parameter values.

pd = makedist('Lognormal','mu',log(20000),'sigma',1)
pd = LognormalDistribution Lognormal distribution mu = 9.90349 sigma = 1

Compute the pdf values.

x = (10:1000:125010)'; y = pdf(pd,x);

Plot the pdf.

plot(x,y) h = gca; h.XTick = [0 30000 60000 90000 120000]; h.XTickLabel = {'0','$30,000','$60,000',...'$90,000','$120,000'};

Compute Lognormal Distribution cdf

Compute the cdf values evaluated at the values inxfor the lognormal distribution with meanmuand standard deviationsigma.

x = 0:0.2:10; mu = 0; sigma = 1; p = logncdf(x,mu,sigma);

Plot the cdf.

plot(x,p) gridonxlabel('x') ylabel('p')

Relationship Between Normal and Lognormal Distributions

IfXfollows the lognormal distribution with parametersµandσ, then log(X) follows the normal distribution with meanµand standard deviationσ. Use distribution objects to inspect the relationship between normal and lognormal distributions.

Create a lognormal distribution object by specifying the parameter values.

pd = makedist('Lognormal','mu',5,'sigma',2)
pd = LognormalDistribution Lognormal distribution mu = 5 sigma = 2

Compute the mean of the lognormal distribution.

mean(pd)
ans = 1.0966e+03

The mean of the lognormal distribution is not equal to themuparameter. The mean of the logarithmic values is equal tomu. Confirm this relationship by generating random numbers.

Generate random numbers from the lognormal distribution and compute their log values.

rng('default');% For reproducibilityx = random(pd,10000,1); logx = log(x);

Compute the mean of the logarithmic values.

m = mean(logx)
m = 5.0033

The mean of the log ofxis close to themuparameter ofx, becausexhas a lognormal distribution.

Construct a histogram oflogxwith a normal distribution fit.

histfit(logx)

The plot shows that the log values ofxare normally distributed.

histfitusesfitdistto fit a distribution to data. Usefitdistto obtain parameters used in fitting.

pd_normal = fitdist(logx,'Normal')
pd_normal = NormalDistribution Normal distribution mu = 5.00332 [4.96445, 5.04219] sigma = 1.98296 [1.95585, 2.01083]

The estimated normal distribution parameters are close to the lognormal distribution parameters 5 and 2.

Compare Lognormal and Burr Distribution pdfs

Compare the lognormal pdf to the Burr pdf using income data generated from a lognormal distribution.

Generate the income data.

rng('default')% For reproducibilityy = random('Lognormal',log(25000),0.65,[500,1]);

Fit a Burr distribution.

pd = fitdist(y,'burr')
pd = BurrDistribution Burr distribution alpha = 26007.2 [21165.5, 31956.4] c = 2.63743 [2.3053, 3.0174] k = 1.09658 [0.775479, 1.55064]

Plot both the Burr and lognormal pdfs of income data on the same figure.

p_burr = pdf(pd,sortrows(y)); p_lognormal = pdf('Lognormal',sortrows(y),log(25000),0.65); plot(sortrows(y),p_burr,'-',sortrows(y),p_lognormal,'-.') title('Burr and Lognormal pdfs Fit to Income Data') legend('Burr Distribution','Lognormal Distribution')

Related Distributions

References

[1] Abramowitz, Milton, and Irene A. Stegun, eds.Handbook of Mathematical Functions: With Formulas, Graphs, and Mathematical Tables. 9. Dover print.; [Nachdr. der Ausg. von 1972]. Dover Books on Mathematics. New York, NY: Dover Publ, 2013.

[2] Evans, M., N. Hastings, and B. Peacock.Statistical Distributions. 2nd ed., Hoboken, NJ: John Wiley & Sons, Inc., 1993.

[3] Lawless, J. F.Statistical Models and Methods for Lifetime Data. Hoboken, NJ: Wiley-Interscience, 1982.

[4] Marsaglia, G., and W. W. Tsang. “A Fast, Easily Implemented Method for Sampling from Decreasing or Symmetric Unimodal Density Functions.”SIAM Journal on Scientific and Statistical Computing. Vol. 5, Number 2, 1984, pp. 349–359.

[5] Meeker, W. Q., and L. A. Escobar.Statistical Methods for Reliability Data. Hoboken, NJ: John Wiley & Sons, Inc., 1998.

[6] Mood, A. M., F. A. Graybill, and D. C. Boes.Introduction to the Theory of Statistics.3rd ed., New York: McGraw-Hill, 1974. pp. 540–541.

See Also

|||||||

Related Topics