Documentation

# gaminv

Gamma inverse cumulative distribution function

## Syntax

X = gaminv(P,A,B)
[X,XLO,XUP] = gaminv(P,A,B,pcov,alpha)

## Description

X = gaminv(P,A,B) computes the inverse of the gamma cdf with shape parameters in A and scale parameters in B for the corresponding probabilities in P. P, A, and B 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 A and B must all be positive, and the values in P must lie on the interval [0 1].

The gamma inverse function in terms of the gamma cdf is

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

where

$p=F\left(x|a,b\right)=\frac{1}{{b}^{a}\Gamma \left(a\right)}\underset{0}{\overset{x}{\int }}{t}^{a-1}{e}^{\frac{-t}{b}}dt$

[X,XLO,XUP] = gaminv(P,A,B,pcov,alpha) produces confidence bounds for X when the input parameters A and B are estimates. pcov is a 2-by-2 matrix containing the covariance matrix of the estimated parameters. alpha has a default value of 0.05, and specifies 100(1-alpha)% confidence bounds. XLO and XUP are arrays of the same size as X containing the lower and upper confidence bounds.

## Examples

This example shows the relationship between the gamma cdf and its inverse function.

a = 1:5;
b = 6:10;
x = gaminv(gamcdf(1:5,a,b),a,b)
x =
1.0000  2.0000  3.0000  4.0000  5.0000

## Algorithms

There is no known analytical solution to the integral equation above. gaminv uses an iterative approach (Newton's method) to converge on the solution.

Download ebook