Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: gamma
From
Maarten Buis <[email protected]>
To
[email protected]
Subject
Re: st: gamma
Date
Mon, 15 Oct 2012 12:19:26 +0200
On Mon, Oct 15, 2012 at 11:47 AM, Jason Rosenberg wrote:
> but I read the help function guide and help lngamma(), but I still get different results for the gamma function from that of RGui(32-bit) as in:
>
> I type this in stata:
> di lngamma(3/4)
>
> and get:
> .20328095
>
> but in R I get gamma(3/4)=1.225417
As was mentioned many times before in this thread: -lngamma()- gives
you the natural logarithm of the gamma function and the natural
logarithm of the gamma function is not the same as the gamma function.
The way to get the gamma function is to type -di exp(lngamma(3/4)) as
exp(ln(something)) = something.
However, as was also mentioned before, you will almost always want to
work with the natural logarithm of the gamma function. The problem is
that the gamma function can become extremely large very quickly, so
large that computers cannot hold that number, so called overflow. For
example try in R: gamma(175) or in Stata: exp(lngamma(175)). However,
the ln(gamma) is a number that computers have no problem with (try in
R: lgamma(175) and in Stata lngamma(175)). So, working in terms of
ln(gamma) you can work with inputs like 175, as long as you rewrote
your formula in terms of ln(gamma) instead of gamma.
Hope this helps,
Maarten
---------------------------------
Maarten L. Buis
WZB
Reichpietschufer 50
10785 Berlin
Germany
http://www.maartenbuis.nl
---------------------------------
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/