Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

norminv

Normal inverse cumulative distribution function

Syntax

x = norminv(p)
x = norminv(p,mu)
x = norminv(p,mu,sigma)
[x,xLo,xUp] = norminv(p,mu,sigma,pCov)
[x,xLo,xUp] = norminv(p,mu,sigma,pCov,alpha)

Description

example

x = norminv(p) returns the inverse of the standard normal cumulative distribution function (cdf), evaluated at the probability values in p.

x = norminv(p,mu) returns the inverse of the normal cdf with mean mu and the unit standard deviation, evaluated at the probability values in p.

example

x = norminv(p,mu,sigma) returns the inverse of the normal cdf with mean mu and standard deviation sigma, evaluated at the probability values in p.

[x,xLo,xUp] = norminv(p,mu,sigma,pCov) also returns the 95% confidence bounds [xLo,xUp] of x when mu and sigma are estimates. pCov is the covariance matrix of the estimated parameters.

example

[x,xLo,xUp] = norminv(p,mu,sigma,pCov,alpha) specifies the confidence level for the confidence interval [pLo,pUp] to be 100(1–alpha)%.

Examples

collapse all

Find an interval that contains 95% of the values from a standard normal distribution.

x = norminv([0.025 0.975])
x = 1×2

   -1.9600    1.9600

Note that the interval x is not the only such interval, but it is the shortest. Find another interval.

xl = norminv([0.01 0.96])
xl = 1×2

   -2.3263    1.7507

The interval x1 also contains 95% of the probability, but it is longer than x.

Compute the inverse of cdf values evaluated at the probability values in p for the normal distribution with mean mu and standard deviation sigma.

p = 0:0.25:1;
mu = 2;
sigma = 1;
x = norminv(p,mu,sigma)
x = 1×5

      -Inf    1.3255    2.0000    2.6745       Inf

Compute the inverse of cdf values evaluated at 0.5 for various normal distributions with different mean parameters.

mu = [-2,-1,0,1,2];
sigma = 1;
x = norminv(0.5,mu,sigma)
x = 1×5

    -2    -1     0     1     2

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

Generate 1000 normal random numbers from the normal distribution with mean 5 and standard deviation 2.

rng('default') % For reproducibility
n = 1000; % Number of samples
x = normrnd(5,2,[n,1]);

Estimate the distribution parameters mean and standard deviation by using normfit.

[muHat,sigmaHat] = normfit(x)
muHat = 4.9347
sigmaHat = 1.9979

With no censoring, muHat is the sample mean and sigmaHat is the square root of the unbiased estimator of the variance. muHat is equal to the MLE of the mean parameter, but sigmaHat is not equal to the MLE of the standard deviation parameter. Transform sigmaHat into the MLE.

sigmaHat = sqrt((n-1)/n)*sigmaHat
sigmaHat = 1.9969

Estimate the covariance of the distribution parameters by using normlike. The function normlike returns an approximation to the asymptotic covariance matrix if you pass the MLEs and the samples used to estimate the MLEs.

[~,pCov] = normlike([muHat,sigmaHat],x)
pCov = 2×2

    0.0040   -0.0000
   -0.0000    0.0020

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

[x,xLo,xUp] = norminv(0.5,muHat,sigmaHat,pCov,0.01)
x = 4.9347
xLo = 4.7721
xUp = 5.0974

x is the inverse cdf value using the normal distribution with the parameters muHat and sigmaHat. The interval [xLo,xUp] is the 99% confidence interval of the inverse cdf value evaluated at 0.5, considering the uncertainty of muHat and sigmaHat using pCov. The 99% confidence interval means that 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, specified as a scalar value or an array of scalar values, where each element is in the range [0,1].

If you specify pCov to compute the confidence interval [xLo,xUp], then p must be a scalar value.

To evaluate the icdf at multiple values, specify x using an array. To evaluate the icdfs of multiple normal distributions, specify mu and sigma using arrays. If one or more of the input arguments p, mu, and sigma are arrays, then the array sizes must be the same. In this case, norminv expands each scalar input into a constant array of the same size as the array inputs. Each element in x is the icdf value of the normal distribution specified by the corresponding elements in mu and sigma, evaluated at the corresponding element in p.

Example: [0.1,0.5,0.9]

Data Types: single | double

Mean of the normal distribution, specified as a scalar value or an array of scalar values.

If you specify pCov to compute the confidence interval [xLo,xUp], then mu must be a scalar value.

To evaluate the icdf at multiple values, specify x using an array. To evaluate the icdfs of multiple normal distributions, specify mu and sigma using arrays. If one or more of the input arguments p, mu, and sigma are arrays, then the array sizes must be the same. In this case, norminv expands each scalar input into a constant array of the same size as the array inputs. Each element in x is the icdf value of the normal distribution specified by the corresponding elements in mu and sigma, evaluated at the corresponding element in p.

Example: [0 1 2; 0 1 2]

Data Types: single | double

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

If you specify pCov to compute the confidence interval [xLo,xUp], then sigma must be a scalar value.

To evaluate the icdf at multiple values, specify x using an array. To evaluate the icdfs of multiple normal distributions, specify mu and sigma using arrays. If one or more of the input arguments p, mu, and sigma are arrays, then the array sizes must be the same. In this case, norminv expands each scalar input into a constant array of the same size as the array inputs. Each element in x is the icdf value of the normal distribution specified by the corresponding elements in mu and sigma, evaluated at the corresponding element in p.

Example: [1 1 1; 2 2 2]

Data Types: single | double

Covariance of the estimates mu and sigma, specified as a 2-by-2 matrix.

If you specify pCov to compute the confidence interval [xLo,xUp], then p, mu, and sigma each must be a scalar value.

You can estimate mu and sigma by using normfit and estimate the covariance of mu and sigma by using normlike. For an example, see Confidence Interval of Inverse Normal cdf Value.

Data Types: single | double

Confidence level for the confidence interval, specified as a scalar in the range (0,1). The confidence level is 100(1–alpha)%, where alpha is 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 in p, returned as a scalar value or an array of scalar values. x is the same size as p, mu, and sigma after any necessary scalar expansion. Each element in x is the icdf value of the normal distribution specified by the corresponding elements in mu and sigma, evaluated at the corresponding element in p.

Lower confidence bound for x, returned as a scalar value or an array of scalar values. xLo has the same size as x.

Upper confidence bound for x, returned as a scalar value or an array of scalar values. xUp has the same size as x.

More About

collapse all

Normal Distribution

The normal distribution is a two-parameter family of curves. The first parameter, µ, is the mean. The second parameter, σ, is the standard deviation.

The standard normal distribution has zero mean and unit standard deviation.

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

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

where

p=F(x|μ,σ)=1σ2πxe(tμ)22σ2dt.

The result x is the solution of the integral equation where you supply the desired probability p.

Algorithms

  • The norminv function uses the inverse complementary error function erfcinv. The relationship between norminv and erfcinv is

    norminv(p)=2erfcinv(2p)

    The inverse complementary error function erfcinv(x) is defined as erfcinv(erfc(x))=x, and the complementary error function erfc(x) is defined as

    erfc(x)=1erf(x)=2πxet2dt.

  • The norminv function computes confidence bounds for x by using the delta method. norminv(p,mu,sigma) is equivalent to mu+sigma*norminv(p,0,1). Therefore, the norminv function estimates the variance of mu+sigma*norminv(p,0,1) using the covariance matrix of mu and sigma by 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 estimate mu, sigma, and pCov from large samples.

Alternative Functionality

norminv is a function specific to normal distribution. Statistics and Machine Learning Toolbox™ also offers the generic function icdf, which supports various probability distributions. To use icdf, create a NormalDistribution probability distribution object and pass the object as an input argument or specify the probability distribution name and its parameters. Note that the distribution-specific function norminv is faster than the generic function icdf.

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. 2nd ed. Hoboken, NJ: John Wiley & Sons, Inc., 1993.

Extended Capabilities

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

Introduced before R2006a

Was this topic helpful?