Talk:Gamma distribution

From Wikipedia, the free encyclopedia
Jump to: navigation, search
WikiProject Statistics (Rated B-class, High-importance)
WikiProject icon

This article is within the scope of the WikiProject Statistics, a collaborative effort to improve the coverage of statistics on Wikipedia. If you would like to participate, please visit the project page or join the discussion.

B-Class article B  This article has been rated as B-Class on the quality scale.
 High  This article has been rated as High-importance on the importance scale.
 
WikiProject Mathematics (Rated B-class, High-importance)
WikiProject Mathematics
This article is within the scope of WikiProject Mathematics, a collaborative effort to improve the coverage of Mathematics on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
Mathematics rating:
B Class
High Importance
 Field: Probability and statistics
One of the 500 most frequently viewed mathematics articles.
This article has comments.

KL Divergence[edit]

Anyone mind if I rephrase the Kullback-Leibler Divergence? The pdf is defined above in terms of shape k and scale theta, but the KL divergence uses theta as shape, and inverse scale beta = theta^-1. Pretty confusing. — Preceding unsigned comment added by 152.3.196.217 (talk) 20:45, 21 September 2011 (UTC)

Important Expectations[edit]

I've found it important to know some expectations which I couldn't find on this page. For example, for the g(x;\alpha,\beta) inverse scale parametrization,

E[\ln{x}]=\psi(\alpha)-\ln{\beta}

Where should this expectation go? Bazugb07 (talk) 16:58, 20 May 2009 (UTC)

Implementing cdf[edit]

So I'm trying to get the cdf into gnuplot to generate a graph except it's not working right

cgamma(x,k,t) = igamma(k, x/t) / gamma(k)

set xtics 0,2
set ytics 0,0.1
set samples 1001
set terminal postscript enhanced color solid lw 2 "Times-Roman" 27
set output

plot [0:100] \
    cgamma(x,1,2) title "{/Times-Italic k} = 1, {/Symbol q} = 2", \
    cgamma(x,2,2) title "{/Times-Italic k} = 2, {/Symbol q} = 2", \
    cgamma(x,3,2) title "{/Times-Italic k} = 3, {/Symbol q} = 2", \
    cgamma(x,4,2) title "{/Times-Italic k} = 4, {/Symbol q} = 2", \
    cgamma(x,5,2) title "{/Times-Italic k} = 5, {/Symbol q} = 2", \
    cgamma(x,5,.5) title "{/Times-Italic k} = 5, {/Symbol q} = 0.5"

but this doesn't give me the correct plots

  • the first two tend to 1
  • third tends to 0.5
  • fourth tends to like .175
  • fifth & sixth tend to the same value at about 0.05

The cgamma function above is the incomplete gamma function over the gamma function...as shown in the article. Which is wrong: the cdf in the article or my gnuplot setup? Cburnett 09:00, 10 Mar 2005 (UTC)

I use the following gnuplot definitions (using names similar to those used by R/Splus):
_ln_dgamma(x, a, b) = a*log(b) - lgamma(a) + (a-1)*log(x) - b*x
dgamma(x, shape, rate) =\
 (x<0)? 0 :\
 (x==0)? ((shape<1)? 1/0 : (shape==1)? rate : 0) :\
 (rate==0)? 0 :\
 exp(_ln_dgamma(x, shape, rate))
pgamma(x, shape, rate) = (x<0)? 0 : igamma(shape, x*rate)
The problem is that "incomplete gamma function" is ambiguous, referring sometimes to the regularized incomplete gamma function. --MarkSweep 16:50, 10 Mar 2005 (UTC)

PDF/CDF confusion[edit]

Ok, so I wrote gnuplot code taken directly from the pdf listed in the article. It's under commons:Image:Gamma distribution pdf.png (see the cdf as well that uses MarkSweep's code from above) but if I take your pdf implementation I get much different curves. The CDF drastically does not agree (see yellow line).

If I can't take the PDF & CDF from the article and get correct plots then I think we need to change the article (even if it's gnuplot that's wrong and explain how some plotters could implement, say, the incomplete gamma function differently). Cburnett 19:47, 10 Mar 2005 (UTC)

I was just about to point out that the PDFs visually don't integrate to the CDFs. I also realize that the gnuplot snippet I posted above uses the same parameterization that R uses, which I suspect is different from the first parameterization used in the article. There is always the issue whether one should use a scale parameter directly or use its inverse instead. I suspect that's the underlying confusion here. --MarkSweep 20:07, 10 Mar 2005 (UTC)
Ah, there we go. I was using theta and you were using beta. I inverted the rate parameter and got the matching CDF. Uploading new one. Cburnett 20:13, 10 Mar 2005 (UTC)
There. *sigh* Finally. :) Cburnett 20:23, 10 Mar 2005 (UTC)
Aargh. I was working on the same plots and just replaced both your versions with new matching PDFs and CDFs. Note that the width is now 1300px, so that scaling it down to 325px will be easier or look better. I used fewer examples to avoid cyan-on-white and yellow-on-white. --MarkSweep 20:40, 10 Mar 2005 (UTC)
Related to this, the mgf is expressed in terms of alpha and beta too. What do you think of adding a note about alternative parameterizations and their uses (see e.g. the more convenient parameterization in Exponential distribution#Bayesian inference)? --MarkSweep 20:47, 10 Mar 2005 (UTC)
mgf updated to match the rest. I don't really care what parameterization we use as long as it's consistent. I prefer greek letters for paramters (just cuz I guess....) so I'd go for the alpha/beta notation over the k/theta. Either way.... More plots to generate if we change it. Cburnett 21:44, 10 Mar 2005 (UTC)

alternative parameterization[edit]

Isn't there an altertanative parameterization for the gamma? Is there a general method wikipedia deals with these? --Pdbailey 17:47, 16 Apr 2005 (UTC)

Okay, foot in mouth... I was confused. --Pdbailey 18:04, 16 Apr 2005 (UTC)

There is in fact an alternative parametrization ... but I'm too lazy to look it up now. Rp 01:46, 6 May 2006 (UTC)

Relation to maxwell-bolzmann[edit]

I removed the following text which doesn't make any sense: "Y \sim \mathrm{Maxwell}(\beta) is a Maxwell-Boltzmann distribution if X \sim \mathrm{Gamma}(\alpha = 3/2, \beta)." I couldn't figure out how to fix it by reading Maxwell-Boltzmann distribution A5 23:13, 16 April 2006 (UTC)

It's fixed (but check it, please). PAR 00:30, 17 April 2006 (UTC)

Real-world examples[edit]

It would be interesting to see some real-world examples of gamma distributions; the article is a bit technical at the moment. It would also be nice to learn why they might be distributed in that way. I know for instance that reaction times in psychological experiments are usually gamma-distributed (rather than the normal distribution that is assumed in the statistical tests based on them) but I'm not sure why. Junes 10:30, 25 May 2006 (UTC)

Yes, more insight into the function in plain language (vs formulae) would be very nice!
Gamma distribution is used to model claim severity in the general insurance industry 195.28.231.13 11:41, 20 February 2007 (UTC)
I also would like more plain language on what generates such distributions and when they are found. Some can be found in the Wikipedia article on the exponential distribution which is a special case of the gamma. It is dscribed as the natutal distribution of intervals between events that occur at a constant random rate(for example, phone calls within a certain period where the rate is steady. Timothy Mak on the AllStat list has also told me that gamma is the expected distribution of time until Bold textnBold text events have occurred.
Also on the AllStat list(in the archive) I have read that on "theoretical grounds" the distribution of rates of return across companies could be Bold textexpectedBold text to be gamma distributed.
I also have read James V. Bradley's article on the "L-shaped" distribution of response times, among other things, and the implications for normality-assuming statistics. Of course some just assume that the Bold textsamplingBold text distribution, the distribution of sample means around the population one, is normal, which is often true even when the actual data are distributed nonnormally. I have also heard of the insurance example.
I am currently working with an L-shaped distribution of the number of times a court case is "distinguished" to those it is "folllowed". I think it might be a gamma, and specifically an exonential, distribution, but am having trouble finding a way to test this hypothesis.
Yours Sincerely,
Alan E. Dunne24.235.165.89 15:32, 26 March 2007 (UTC)
Kotz and Norman Lloyd Johnson in Continuous Univariate Distributions 1970, chapter 17, give several examples Of the "time-to-event" and "insured casualty" types and also fibre-diameter measurements of wool tops, "internal comparisons in multipurpose experiments" and unspecified "medical applications"
Yours Sincerely,
Alan E. Dunne24.235.165.89 15:45, 2 April 2007 (UTC), With Respect
Further work with my ratio of court citation types has shown that it does not approximate the exponential but rather a gamma distribution with k less than 1 (a bit more than 0.5) I would be interested to hear what this might mean
Yours Sincerely
Alan E. Dunne

Cite? Approximation when some x = 0?[edit]

The approximation provided for k is very useful in general, but what is one to do when x_i = 0, for some i?

Also, it would be nice to have a cite, here, but neither of the listed references has this formula, AFAICT.

Ken K 30 Oct 2006

Theta or 1/theta ?[edit]

To me it seems that the in the probability density function we should have \theta\,^{-k} instead of \theta\,^k since all the other characteristics that are shown seem to be calculated with 1/\theta\, . I checked http://mathworld.wolfram.com/GammaDistribution.html to verify this but I would be happier if a more experienced wiki-editor/mathematician changed the article. Sorry if I am incorrect about this.

Artagas 20 Nov 2006

Both parameterizations exist, and both are already covered in the article (someone introduced a mistake recently, now corrected). In the first version, with parameters (k,\theta), the parameter θ is a scale parameter. The second parameterization, in terms of (\alpha,\beta), uses an inverse scale parameter and has advantages when the Gamma distribution is used as a conjugate prior (see e.g. exponential distribution#Bayesian inference). --MarkSweep (call me collect) 02:59, 20 November 2006 (UTC)

Graphs of pdf misleading[edit]

The graph presented on the main page for k=1, theta = 2 is misleading. The function actually diverges to infinitiy as x tends to zero under these parameters. This is an interesting property of the gamma distrubution and should be indicated in the graph.

isn't it just an exponential distribution in the case of k=1? (in other words, what you say is not true.) MisterSheik 02:07, 27 March 2007 (UTC)

Confusion about parameter names[edit]

With Respect

In the article gamma is a function of x, k, and theta, or alternatively paramtrized by alpha and beta but there seem to be many other names floating around. Gammma is sometimes said to have parameters r and lambda, or n and lambda. I have seen alpha and beta called A and B. There is also a 1/lambda parameter. Which of alpha or beta is 1/theta is and which parameter equals one are also sources of confusion. I have also seem k(I think) called kappa.
There are also references on the Allstat list and elsewhere to "three-parameter gamma" and a constant a.
Yours Sincerely,
Alan E. Dunne

24.235.165.89 15:55, 2 April 2007 (UTC)

They're just different names of the same things. Except, three-parameter gamma, which just has a location parameter, and is a trivial modification. I think it would be more confusing to include it. MisterSheik 17:44, 17 April 2007 (UTC)

infinitely divisible[edit]

It would be nice to add that the Gamma distribution is infinitely divisible, and to provide its L\'evy measure

Yes... MisterSheik 17:12, 17 April 2007 (UTC)

exponential family[edit]

In the article it says

The Gamma distribution is a two-parameter exponential family ...

Shouldn't it rather be "... is a one-parameter exponential family ..." ? I am aware that the Gamma distribution itself has two parameters, but in the context of exponential families, the number of parameters has a different meaning, in my opinion. Unfortunately this distinction is not made in the article on exponential families (maybe it should be?). Can another mathematician/statistician verify this? 134.60.66.52 14:37, 17 April 2007 (UTC)

No, the exponential family also has two parameters :) MisterSheik 17:06, 17 April 2007 (UTC)
Yes, meanwhile I noticed that too. I apologize for my mistake, I got confused by a particular setting where one of the parameters was considered a nuisance parameter, effectively making it a one parameter exponential family. Sorry again. --134.60.66.52 12:30, 18 April 2007 (UTC)
No worries... :) MisterSheik 12:41, 18 April 2007 (UTC)

Image[edit]

It would be useful if the images at the top of the page would include variations of θ for constant k. Currently, no two curves have the same k value. --EyrianAtWork 13:50, 11 July 2007 (UTC)

I disagree. θ is a scale parameter, and the curve doesn't change shape with θ. A plot in the scale parameter article might be useful though. -- Aastrup 20:19, 18 July 2007 (UTC)
I agree with @EvrianAtWork, I think at least on of the curves having the same k value would be helpful since a beginner might not exactly know what's meant by a "scale parameter", but will easily see the effect of changing θ if it was shown. Monsterman222 (talk) 06:53, 29 July 2014 (UTC)

Gamma or Γ?[edit]

I must admit that most of my Statistics books aren't written in English, but when it comes to the two ways of notation

X \sim \Gamma(k, \theta) \,\,\mathrm{ or }\,\, X \sim \textrm{Gamma}(k, \theta)

it is clearly the first which is used most often. This is why I'm changing the notation in the article. Aastrup 21:58, 18 July 2007 (UTC)

The use of \Gamma is confusing as it refers to the gamma function either Gamma(a,b) or Ga(a,b) are more common.

Gentry White —Preceding unsigned comment added by 152.1.95.168 (talk) 19:20, 15 July 2008 (UTC)

Do not use the gamma function to refer to a gamma distribution. There are to many dang gamma symbols on the page which makes it confusing which is being referred to. Gammma(a, b) is obviously the most clear. —Preceding unsigned comment added by 69.204.243.36 (talk) 22:08, 7 December 2008 (UTC)

Another plea to restrict \Gamma to the gamma function (as it's universal throughout mathematics) and use Gamma for the distribution.
A similar thing happens with the beta distribution. Since its parameters are conventionally \alpha and \beta, it's just unacceptable to refer to the distribution as \beta(\alpha, \beta)! Much better to write \mathrm{Beta}(\alpha, \beta), and similarly \mathrm{Gamma}(\cdot, \cdot) (choose your parameters). --88.109.216.145 (talk) 23:02, 5 November 2009 (UTC)

The top of the webpage says not to confuse the "Gamma" distribution with the Gamma function. Throughout the webpage, however, the single-parameter \Gamma function (greek symbol) is used but nowhere is this explained as the "Gamma" function referred to at the top. This should be explained, and a link to the wikipedia page for the Gamma function should be provided. Craniator (talk) 23:34, 17 March 2013 (UTC) — Preceding unsigned comment added by Craniator (talkcontribs) 23:31, 17 March 2013 (UTC)

Proof of some of the basic stuff[edit]

I've made this little example on the page concerning charactericstic functions

The Gamma distribution with scale parameter θ and a shape parameter k has the characteristic function
(1 - \theta\,i\,t)^{-k}\,\!
Now suppose that we have
X \sim \Gamma(k_1,\theta) \mbox{ and } Y \sim \Gamma(k_2,\theta)
with X and Y independent from each other, and we wish to know what the distribution of X + Y is. The characteristic functions are
\varphi_X(t)=(1 - \theta\,i\,t)^{-k_1},\,\qquad \varphi_Y(t)=(1 - \theta\,i\,t)^{-k_2}

which by indedendence and the basic properties of characteristic function leads to

\varphi_{X+Y}(t)=\varphi_X(t)\varphi_Y(t)=(1 - \theta\,i\,t)^{-k_1}(1 - \theta\,i\,t)^{-k_2}=\left(1 - \theta\,i\,t\right)^{-(k_1+k_2)}
This is the characteristic function of the gamma distribution scale parameter θ and shape parameter k1 + k2, and we therefore conclude
X+Y \sim \Gamma(k_1+k_2,\theta)
The result can be expanded to n independent gamma distributed random variables with the same cale parameter and we get
\forall i \in \{1,\ldots, n\} :  X_i \sim \Gamma(k_i,\theta) \qquad \Rightarrow \qquad \sum_{i=1}^n X_i \sim \Gamma\left(\sum_{i=1}^nk_i,\theta\right)

I think it might be nice to have on the gamma districution page a well. Any thoughts? - Aastrup 12:00, 28 July 2007 (UTC)

sir i need some information about statistical distributions[edit]

sir please tell me the applications from real life and some solved examples of {Gamma Distribution,Weibul Dist,and exponential distribution}sir i will b very thank full to you.u can send me these information on "a_smile4me@yahoo.com".i will wait ur response. —Preceding unsigned comment added by 58.65.201.212 (talk) 18:48, 20 October 2007 (UTC)

Generating variables[edit]

Can anyone review the changes made by ClaudeLo? I wrote the original algorithm (rather adapted and fixed it based on some book) but no longer study math and my work is not math-related, so I do not quite trust my skills. -- Paul Pogonyshev (talk) 00:04, 22 November 2007 (UTC)

I'm not sure if the current version is these changes, but the current algorithm does not work for me. It consistently generates too many extremely high values. I also can't tell what the point of V1 is in that algorithm; it chooses between two branches, but there should be no need to do that in an acceptance-rejection method.
Here is a quickly hacked together C implementation. It's easily verified due to the simple rejection criterion:
double rand_flat() {
    double val = (double) rand() / (double) RAND_MAX;
    return val;
}
 
double gamma(const double k, const double theta)
{
    double delta = k - trunc(k);
    double x, y;
    bool done = 0;
    do {
        //   Generate x and y — independent uniformly distributed on (0, 1] variables.
        x = rand_flat();
        y = rand_flat();
        // Accept if y < P(x)
        if (y < (pow(x, delta - 1) * exp(-x) / tgamma(delta))) { done = 1; }
    } while (!done);
 
    double rest = 0;
    for (int i = 0; i < trunc(k); i++) {   
        rest += log(rand_flat());
    }
 
    double val = (x - rest) / theta;
    return val;
}

--Dyfrgi (talk) 09:26, 6 January 2010 (UTC)

This code above is bogus for the simple reason that this samples from the area below the probability distribution but assumes that the density lives with the unit square but that's very false. Close to zero the PDF far exceeds 1 and appreciable mass is distributed on x>1. Sorry! —Preceding unsigned comment added by 140.247.239.43 (talk) 05:04, 6 March 2010 (UTC)

Four standard references to reliable algorithms for generating gamma variates have been inserted above the explicit algorithm that is given without proof or source. It does not appear to be the algorithm in Ahrens and Dieter. Can anyone identify a source for the algorithm given? Does the article need to include an explicit (but unsourced) algorithm when one is available in the linked PDF of Ahrens and Dieter? Mathstat (talk) 11:49, 26 February 2012 (UTC)

Parameter Estimation[edit]

Is the MLE parameter estimation for theta wrong? should it be k*xbar instead of xbar/k? --67.109.70.3 (talk) 01:41, 19 June 2008 (UTC)

Nah, it seems correct. Recall that the mean = k * theta and is estimated by xbar. So it makes sense that theta is estimated by xbar/k. --Fangz (talk) 11:27, 19 June 2008 (UTC)


I think have found a mistake of the same kind in Chow, V. T. Maidment, D. and Mays, L. W. "Applied Hydrology" 1988. Mc Graw Hill, International Edition. In table 11.5.1 the scale parameter is named lambda and corresponds to the inverse of theta, the scale parameter described in this article. It is stated that the estimator for lamba is sx/sqrt(k), where sx is the standard deviation and k is the shape parameter. Being lambda the inverse of theta, it estimation should be sqrt(k)/sx. Could anyone confirm this? J. (talk) 12:33, 19 December 2008

Reference for entropy[edit]

Can someone post a reference for the entropy computation for the gamma density ? It's mentioned on the side table without a reference. —Preceding unsigned comment added by 128.95.224.31 (talk) 17:55, 13 October 2008 (UTC)

as in the reference from the Differential_entropy article.
Lazo, A. and P. Rathie. On the entropy of continuous probability distributions Information Theory, IEEE Transactions on, 1978. 24(1): p. : 120-122 129.242.167.37 (talk) 15:54, 26 October 2011 (UTC)

Right margin too near to tables in some math articles[edit]

(Question moved from MediaWiki talk:Common.css; this would have been best asked at the Wikipedia:Help desk)

With Firefox 3.0.7 on Ubuntu, when I look at Gamma distribution, I see that the right margin of the left text column is too near to the right column where the picture and the table are. There should be some more margin between the two columns. --Pot (talk) 08:46, 11 March 2009 (UTC)

This article uses template{{Probability distribution}}. Look at the documentation for the template and you will see it has a parameter for marginleft. I suggest you start with a value of 2em and fudge from there. The default margin is 1em; if you think that should be changed, discuss it on the template talk. --—— Gadget850 (Ed) talk - 10:47, 11 March 2009 (UTC)

Relation to dirac distribution[edit]

I'm pretty sure it shouldn't be in the article, but it's interesting anyway. The Gamma(α,c/α) distribution tends to a dirac distribution centered around c as α->infinity. This is easily visible by taking β=4/α (so that αβ=4), for large α it tends to dirac distribution. (or you can see that the variance is c^2/α, which tends to zero in such a process). —Preceding unsigned comment added by 131.155.212.223 (talk) 13:49, 4 November 2010 (UTC)

Gamma distribution in rainfall analysis[edit]

There is a comment on the main page that a citation is needed in relation to the use of the gamma distribution for rainfall analysis.

There is a good discussion of the use of the gamma distribution to fit monthly rainfall data on p303-307 of Jones et al. (2009)

Jones, O., Maillardet, R. and Robinson, A. (2009) Introduction to scientific programming and simulation using R. CRC Press. [1]

Tony.ladson (talk) 01:29, 1 September 2011 (UTC)

Distinguishing between k and alpha[edit]

What's the purpose of using two different letters for the shape parameter in the two different representations of the distribution? I think it just adds clutter.

Domminico (talk) 19:12, 25 April 2012 (UTC)

MLE[edit]

Rather than waving our swords around showing how clever we are at solving for the MLE under the standard parameterisation, would it not be simpler to present the alpha, mu parameterisation and solve that instead? — Preceding unsigned comment added by 90.218.192.173 (talk) 19:56, 11 October 2012 (UTC)

Relation with Chi Squared[edit]

There is a typo in relations with Chi-Squared distribution, as \theta = \frac 12, but for cX \theta = 2c, which give a contradiction at c=1. Correct version is \theta = 2 — Preceding unsigned comment added by Bitlemon (talkcontribs) 19:15, 3 December 2013 (UTC)

Scaling section[edit]

The Scaling section currently reads:

If

X \sim \mathrm{Gamma}(k, \theta),

then for any c > 0,

cX \sim \mathrm{Gamma}( k, c\theta).

Hence the use of the term "scale parameter" to describe θ.

Equivalently, if

X \sim \mathrm{Gamma}(\alpha, \beta),

then for any c > 0,

cX \sim \mathrm{Gamma}( \alpha, \beta/c).

Hence the use of the term "inverse scale parameter" to describe β.

The second set of equations contradicts the first: the final maths line should read

cX \sim \mathrm{Gamma}( \alpha, \beta c).

I'm not sure what correction should be made, though, because I don't know what the point of the "inverse scale parameter" thing was.

Smaug123 (talk) 13:59, 4 February 2014 (UTC)

Notation[edit]

I find the inconsistency of notation throughout this long article quite confusing at some places. The most significant problem is the mixing of the two different sets of parametrization in different places. For example, in the Related Distribution section, it is often not clear which parametrization is used (e.g. "If X ~ Gamma(1, λ), then X has an exponential distribution with rate parameter λ"). As this article belongs to the area of Probability, I would suggest to preferentially use the α, β parametrization that is much more common in probability and statistics literature and more consistent with other Wikipedia articles on probability distributions (e.g. exponential distribution). Also, α and k are both shape parameter, it will be much clearer to stick with one notation. I would also suggest using α throughout and only use k where the shape parameter is assumed to be an integer (i.e. where Erlang distribution is mentioned). Beside this, log and ln are also used interchangeably in different places. The greek letter \Gamma is used for both the Gamma function and the Gamma distribution, which can be potentially confusing as well.

  1. ^ Jones, O., Maillardet, R. and Robinson, A. (2009) Introduction to scientific programming and simulation using R. CRC Press.