[R] over/under flow
William H. Asquith
wasquith at austin.rr.com
Sun Jul 3 23:00:40 CEST 2005
Great, but to followup, how do I select the bounds (B,E) on the root
for an arbitrary machine?
OVER = uniroot(function(x) lgamma(x)-log(.Machine$double.xmax),
c(B,E))$root
If uniroot() is fast enough, is it appropriate for me to set B at say 1
and E at log(.Machine$double.max)? Suggestions on do this the proper
"R way"? Perhaps this . . .
OVER = uniroot(function(x) lgamma(x)-log(.Machine$double.xmax),
c(1,log(.Machine$double.xmax)))$root
I am working on a package so different machines will be involved thus
simple 171,172 might not be the best idea for the root?
THANKS!
-wha
On Jul 3, 2005, at 3:43 PM, Peter Dalgaard wrote:
> "William H. Asquith" <wasquith at austin.rr.com> writes:
>
>> I am porting some FORTRAN to R in which an Inf triggers an if(). The
>> trigger is infinite on exp(lgamma(OVER)). What is the canonical R
>> style of determining OVER when exp(OVER)== Inf? The code structure
>> that I am
>> porting is best left intact--so I need to query R somehow to the value
>> of OVER that causes exp(lgamma(OVER)) to equal Inf.
>>
>> On my system,
>> exp(lgamma(171)) is about first to equal Inf.
>>
>> I asked similar question a few weeks ago on exp(OVER) and got the
>> answer back as log(.Machine$double.xmax). I now have the lgamma
>> involved. I think that answer is what is OVER such the
>>
>> .Machine$double.xmax = lgamma(OVER),
>
> Not quite... (see below)
>
>> but I am not sure how to invert or solve for OVER
>
>
>> uniroot(function(x) lgamma(x)-log(.Machine$double.xmax), c(171,172))
> $root
> [1] 171.6244
>
> $f.root
> [1] -1.462051e-07
>
> $iter
> [1] 3
>
> $estim.prec
> [1] 6.103516e-05
>
>
> --
> 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
>
More information about the R-help
mailing list