The gamma pdf is

$$y=f(x|a,b)=\frac{1}{{b}^{a}\Gamma (a)}{x}^{a-1}{e}^{\frac{-x}{b}}$$

where Γ( · ) is the Gamma function.

The gamma distribution models sums of exponentially distributed random variables.

The gamma distribution family is based on two parameters. The chi-square and exponential distributions, which are children of the gamma distribution, are one-parameter distributions that fix one of the two gamma parameters.

The gamma distribution has the following relationship with the incomplete Gamma function.

$$f\left(x|a,b\right)=\text{gammainc}\left(\frac{x}{b},a\right)$$

When *a* is large, the gamma distribution
closely approximates a normal distribution with the advantage that
the gamma distribution has density only for positive real numbers.

Suppose you are stress testing computer memory chips and collecting data on their lifetimes. You assume that these lifetimes follow a gamma distribution. You want to know how long you can expect the average computer memory chip to last. Parameter estimation is the process of determining the parameters of the gamma distribution that fit this data best in some sense.

One popular criterion of goodness is to maximize the likelihood
function. The likelihood has the same form as the gamma pdf above.
But for the pdf, the parameters are known constants and the variable
is *x*. The likelihood function
reverses the roles of the variables. Here, the sample values (the *x*'s) are already observed. So they
are the fixed constants. The variables are the unknown parameters.
MLE involves calculating the values of the parameters that give the
highest likelihood given the particular set of data.

The function `gamfit`

returns
the MLEs and confidence intervals for the parameters of the gamma
distribution. Here is an example using random numbers from the gamma
distribution with *a = *10* *and *b = *5.

lifetimes = gamrnd(10,5,100,1); [phat, pci] = gamfit(lifetimes)

phat = 10.9821 4.7258 pci = 7.4001 3.1543 14.5640 6.2974

Note `phat(1)`

= *â* and `phat(2)`

= $$\widehat{b}$$. The MLE for parameter *a* is
10.98, compared to the true value of 10. The 95% confidence interval
for *a* goes from 7.4 to* *14.6,
which includes the true value.

Similarly the MLE for parameter *b* is 4.7,
compared to the true value of 5. The 95% confidence interval for *b* goes
from 3.2 to 6.3, which also includes the true value.

In the life tests you do not know the true value of *a *and* b *so
it is nice to have a confidence interval on the parameters to give
a range of likely values.

Compute the pdf of a gamma distribution with parameters `A = 100`

and `B = 10`

. For comparison, also compute the pdf of a normal distribution with parameters `mu = 1000`

and `sigma = 100`

.

x = gaminv((0.005:0.01:0.995),100,10); y = gampdf(x,100,10); y1 = normpdf(x,1000,100);

Plot the pdfs of the gamma distribution and the normal distribution on the same figure.

figure; plot(x,y,'-',x,y1,'-.')

Was this topic helpful?