I have to calculate some formula like: gamma(x)/(gamma(x+y) and I observed that for relatively big values of x, R returns infinity and so cannot compute the formula. Is it possible to force R to give the real value of gamma(x) instead of Inf ? thanks
Florent Bresson schrieb:>I have to calculate some formula like: > >gamma(x)/(gamma(x+y) > >and I observed that for relatively big values of x, R >returns infinity and so cannot compute the formula. Is >it possible to force R to give the real value of >gamma(x) instead of Inf ? > >thanks > >______________________________________________ >R-help at stat.math.ethz.ch mailing list >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > > >Have a look at lgamma. hth D. Trenkler -- Dietrich Trenkler c/o Universitaet Osnabrueck Rolandstr. 8; D-49069 Osnabrueck, Germany email: Dietrich.Trenkler at Uni-Osnabrueck.de
Florent Bresson <f_bresson at yahoo.fr> writes:> I have to calculate some formula like: > > gamma(x)/(gamma(x+y) > > and I observed that for relatively big values of x, R > returns infinity and so cannot compute the formula. Is > it possible to force R to give the real value of > gamma(x) instead of Inf ?No, it is overflowing the floating point representation. How about using lgamma? That's basically what it is for. -- O__ ---- Peter Dalgaard ??ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
On 05-Dec-05 Florent Bresson wrote:> I have to calculate some formula like: > > gamma(x)/(gamma(x+y) > > and I observed that for relatively big values of x, R > returns infinity and so cannot compute the formula. Is > it possible to force R to give the real value of > gamma(x) instead of Inf ? > > thanksYou should have more success with exp(lgamma(x) - lgamma(x+y)) E.g. > gamma(250) [1] Inf > exp(lgamma(250)-lgamma(251)) [1] 0.004 = 1/250 (as it should). Does this help? Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk> Fax-to-email: +44 (0)870 094 0861 Date: 05-Dec-05 Time: 16:29:21 ------------------------------ XFMail ------------------------------