[R] Beyond double-precision?
spencer.graves at prodsyse.com
Sat May 9 17:01:40 CEST 2009
The harmonic mean is exp(mean(logs)). Therefore, log(harmonic
mean) = mean(logs).
Does this make sense?
> Yes, all of the numbers are positive. I actually have a Bayesian posterior
> sample of log likelihoods [i.e. thousands of ln(likelihood) scores]. I want
> to calculate the harmonic mean of these likelihoods, which means I need to
> convert them back into likelihoods [i.e. e^ln(likelihood)], calculate the
> harmonic mean, and then take the log of the mean. I have done this before
> in Mathematica, but I have a simulation pipeline written almost entirely in
> R, so it would be nice if I could do these calculations in R.
> If R cannot handle such small values, then perhaps there's a way to
> calculate the harmonic mean from the log likelihood scores without
> converting back to likelihoods? I am a biologist, not a mathematician, so
> any recommendations are welcome! Thanks! -Jamie
> spencerg wrote:
>> Are all your numbers positive? If yes, have you considered using
>> I would guess it is quite rare for people to compute likelihoods.
>> Instead I think most people use log(likelihoods). Most of the
>> probability functions in R have an option of returning the logarithms.
>> Hope this helps.
>> joaks1 wrote:
>>> I need to perform some calculations with some extremely small numbers
>>> likelihood values on the order of 1.0E-16,000). Even when using the
>>> double() function, R is rounding these values to zero. Is there any way
>>> get R to deal with such small numbers?
>>> For example, I would like to be able to calculate e^-10000 (i.e.
>>> exp(-10000)) without the result being rounded to zero.
>>> I know I can do it in Mathematica, but I would prefer to use R if I can.
>>> Any help would be appreciated!
>>> Many Thanks in Advance!
>> R-help at r-project.org mailing list
>> PLEASE do read the posting guide
>> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help