Main Content

logninv

Lognormal inverse cumulative distribution function

Description

x= logninv(p)returns the inverse of the standard lognormal cumulative distribution function (cdf), evaluated at the probability values inp. In the standard lognormal distribution, the mean and standard deviation of logarithmic values are 0 and 1, respectively.

x= logninv(p,mu)returns the inverse of the lognormal cdf with the distribution parametersmu(mean of logarithmic values) and 1 (standard deviation of logarithmic values), evaluated at the probability values inp.

example

x= logninv(p,mu,sigma)returns the inverse of the lognormal cdf with the distribution parametersmu(mean of logarithmic values) andsigma(standard deviation of logarithmic values), evaluated at the probability values inp.

[x,xLo,xUp] = logninv(p,mu,sigma,pCov)also returns the 95% confidence bounds [xLo,xUp] ofxusing the estimated parameters (muandsigma) and their covariance matrixpCov.

[x,xLo,xUp] = logninv(p,mu,sigma,pCov,alpha)specifies the confidence level for the confidence interval [xLo,xUp] to be100(1α)%.

Examples

collapse all

Compute the inverse of cdf values evaluated at the probability values inpfor the lognormal distribution with meanmuand standard deviationsigma.

p = 0.005:0.01:0.995; mu = 1; sigma = 0.5; x = logninv(p,mu,sigma);

Plot the inverse cdf.

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

Find the maximum likelihood estimates (MLEs) of the lognormal distribution parameters, and then find the confidence interval of the corresponding inverse cdf value.

Generate 1000 random numbers from the lognormal distribution with the parameters 5 and 2.

rng('default')% For reproducibilityn = 1000;% Number of samplesx = lognrnd(5,2,[n,1]);

Find the MLEs for the distribution parameters (mean and standard deviation of logarithmic values) by usingmle.

phat = mle(x,'distribution','LogNormal')
phat =1×24.9347 1.9969
muHat = phat(1); sigmaHat = phat(2);

Estimate the covariance of the distribution parameters by usinglognlike. The functionlognlikereturns an approximation to the asymptotic covariance matrix if you pass the MLEs and the samples used to estimate the MLEs.

[~,pCov] = lognlike(phat,x)
pCov =2×20.0040 -0.0000 -0.0000 0.0020

Find the inverse cdf value at 0.5 and its 99% confidence interval.

[x,xLo,xUp] = logninv(0.5,muHat,sigmaHat,pCov,0.01)
x = 139.0364
xLo = 118.1643
xUp = 163.5953

xis the inverse cdf value using the lognormal distribution with the parametersmuHatandsigmaHat. The interval[xLo,xUp]is the 99% confidence interval of the inverse cdf value evaluated at 0.5, considering the uncertainty ofmuHatandsigmaHatusingpCov. The 99% confidence interval means the probability that[xLo,xUp]contains the true inverse cdf value is 0.99.

Input Arguments

collapse all

Probability values at which to evaluate the inverse of the cdf (icdf), specified as a scalar value or an array of scalar values, where each element is in the range[0,1].

If you specifypCovto compute the confidence interval[xLo,xUp], thenpmust be a scalar value.

To evaluate the icdf at multiple values, specifypusing an array. To evaluate the icdfs of multiple distributions, specifymuandsigmausing arrays. If one or more of the input argumentsp,mu, andsigmaare arrays, then the array sizes must be the same. In this case,logninvexpands each scalar input into a constant array of the same size as the array inputs.Each element inxis the icdf value of the distribution specified by the corresponding elements inmuandsigma, evaluated at the corresponding element inp.

Example:[0.1,0.5,0.9]

Data Types:single|double

Mean of logarithmic values for the lognormal distribution, specified as a scalar value or an array of scalar values.

If you specifypCovto compute the confidence interval[xLo,xUp], thenmumust be a scalar value.

To evaluate the icdf at multiple values, specifypusing an array. To evaluate the icdfs of multiple distributions, specifymuandsigmausing arrays. If one or more of the input argumentsp,mu, andsigmaare arrays, then the array sizes must be the same. In this case,logninvexpands each scalar input into a constant array of the same size as the array inputs.Each element inxis the icdf value of the distribution specified by the corresponding elements inmuandsigma, evaluated at the corresponding element inp.

Example:[0 1 2; 0 1 2]

Data Types:single|double

Standard deviation of logarithmic values for the lognormal distribution, specified as a positive scalar value or an array of positive scalar values.

If you specifypCovto compute the confidence interval[xLo,xUp], thensigmamust be a scalar value.

To evaluate the icdf at multiple values, specifypusing an array. To evaluate the icdfs of multiple distributions, specifymuandsigmausing arrays. If one or more of the input argumentsp,mu, andsigmaare arrays, then the array sizes must be the same. In this case,logninvexpands each scalar input into a constant array of the same size as the array inputs.Each element inxis the icdf value of the distribution specified by the corresponding elements inmuandsigma, evaluated at the corresponding element inp.

Example:[1 1 1; 2 2 2]

Data Types:single|double

Covariance of the estimatesmuandsigma, specified as a 2-by-2 matrix.

If you specifypCovto compute the confidence interval[xLo,xUp], thenp,mu, andsigmamust be scalar values.

You can estimate the maximum likelihood estimates ofmuandsigmaby usingmle, and estimate the covariance ofmuandsigmaby usinglognlike. For an example, seeConfidence Interval of Inverse Lognormal cdf Value.

Data Types:single|double

Significance level for the confidence interval, specified as a scalar in the range (0,1). The confidence level is100(1α)%, wherealphais the probability that the confidence interval does not contain the true value.

Example:0.01

Data Types:single|double

Output Arguments

collapse all

icdf values, evaluated at the probability values inp, returned as a scalar value or an array of scalar values.xis the same size asp,mu, andsigmaafter any necessary scalar expansion.Each element inxis the icdf value of the distribution specified by the corresponding elements inmuandsigma, evaluated at the corresponding element inp.

Lower confidence bound forx, returned as a scalar value or an array of scalar values.xLohas the same size asx.

Upper confidence bound forx, returned as a scalar value or an array of scalar values.xUphas the same size asx.

More About

collapse all

Lognormal Distribution

The lognormal distribution is a probability distribution whose logarithm has a normal distribution.

The lognormal inverse function is defined in terms of the lognormal cdf as

x = F 1 ( p | μ , σ ) = { x : F ( x | μ , σ ) = p }

where

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

Algorithms

  • The functionlogninvuses the inverse complementary error functionerfcinv. The relationship betweenlogninvanderfcinvis

    logninv ( p , 0 , 1 ) = exp ( 2 erfcinv ( 2 p ) ) .

    The inverse complementary error functionerfcinv(x)is defined aserfcinv(erfc(x))=x, and the complementary error functionerfc(x)is defined as

    erfc ( x ) = 1 erf ( x ) = 2 π x e t 2 d t .

  • Thelogninvfunction computes confidence bounds forxby using the delta method.log(logninv(p,mu,sigma))is equivalent tomu + sigma*log(logninv(p,0,1)). Therefore, thelogninvfunction estimates the variance ofmu + sigma*log(logninv(p,0,1))using the covariance matrix ofmuandsigmaby the delta method, and finds the confidence bounds using the estimates of this variance. The computed bounds give approximately the desired confidence level when you estimatemu,sigma, andpCovfrom large samples.

Alternative Functionality

  • logninv是特定于对数正态函数distribution. Statistics and Machine Learning Toolbox™ also offers the generic functionicdf支持各种概率金宝appability distributions. To useicdf, create aLognormalDistributionprobability distribution object and pass the object as an input argument or specify the probability distribution name and its parameters. Note that the distribution-specific functionlogninvis faster than the generic functionicdf.

References

[1] Abramowitz, M., and I. A. Stegun.Handbook of Mathematical Functions. New York: Dover, 1964.

[2] Evans, M., N. Hastings, and B. Peacock.Statistical Distributions. Hoboken, NJ: Wiley-Interscience, 2000. pp. 102–105.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Introduced before R2006a