Talk:Gamma distribution
From Wikipedia, the free encyclopedia
Contents |
[edit] Implementing cdf
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)
[edit] PDF/CDF confusion
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)
[edit] alternative parameterization
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)
[edit] Relation to maxwell-bolzmann
I removed the following text which doesn't make any sense: " is a Maxwell-Boltzmann distribution if
." 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)
[edit] Real-world examples
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)
Samuel 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)
[edit] Cite? Approximation when some x = 0?
The approximation provided for k is very useful in general, but what is one to do when xi = 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
[edit] Theta or 1/theta ?
To me it seems that the in the probability density function we should have instead of
since all the other characteristics that are shown seem to be calculated with
. 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,θ), the parameter θ is a scale parameter. The second parameterization, in terms of (α,β), 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)
[edit] Graphs of pdf misleading
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)
[edit] Confusion about parameter names
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)
It would be nice to add that the Gamma distribution is infinitely divisible, and to provide its L\'evy measure