# norminv

Normal inverse cumulative distribution function

## Syntax

`X = norminv(P,mu,sigma)[X,XLO,XUP] = norminv(P,mu,sigma,pcov,alpha)`

## Description

`X = norminv(P,mu,sigma)` computes the inverse of the normal cdf using the corresponding mean `mu` and standard deviation `sigma` at the corresponding probabilities in `P`. `P`, `mu`, and `sigma` can be vectors, matrices, or multidimensional arrays that all have the same size. A scalar input is expanded to a constant array with the same dimensions as the other inputs. The parameters in `sigma` must be positive, and the values in `P` must lie in the interval [0 1].

`[X,XLO,XUP] = norminv(P,mu,sigma,pcov,alpha)` produces confidence bounds for `X` when the input parameters `mu` and `sigma` are estimates. `pcov` is the covariance matrix of the estimated parameters. `alpha` specifies 100(1 - `alpha`)% confidence bounds. The default value of `alpha` is `0.05`. `XLO` and `XUP` are arrays of the same size as `X` containing the lower and upper confidence bounds.

The function `norminv` computes confidence bounds for `P` using a normal approximation to the distribution of the estimate

$\stackrel{^}{\mu }+\stackrel{^}{\sigma }q$

where q is the `P`th quantile from a normal distribution with mean 0 and standard deviation 1. The computed bounds give approximately the desired confidence level when you estimate `mu`, `sigma`, and `pcov` from large samples, but in smaller samples other methods of computing the confidence bounds may be more accurate.

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

$x={F}^{-1}\left(p|\mu ,\sigma \right)=\left\{x:F\left(x|\mu ,\sigma \right)=p\right\}$

where

$p=F\left(x|\mu ,\sigma \right)=\frac{1}{\sigma \sqrt{2\pi }}{\int }_{-\infty }^{x}{e}^{\frac{-{\left(t-\mu \right)}^{2}}{2{\sigma }^{2}}}dt$

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

## Examples

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

```x = norminv([0.025 0.975],0,1) x = -1.9600 1.9600```

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

```xl = norminv([0.01 0.96],0,1) xl = -2.3263 1.7507```

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