[R] how to calculate this natural logarithm
Mike Marchywka
marchywka at hotmail.com
Tue Jan 11 13:53:16 CET 2011
> Date: Sun, 9 Jan 2011 12:57:49 +0000
> From: cgw at witthoft.com
> To: r-help at r-project.org
> Subject: Re: [R] how to calculate this natural logarithm
>
>
>
> You could re-do part of your code to run with mpfr-class variables, and use
> this function:
> # mpfr choose(n,k)
> rmpfac<-function(n,k,prec=50)
> factorial(mpfr(n,prec))/factorial(mpfr(k,prec))/factorial(mpfr(n-k,prec))
> Converting into and out of mpfr may not be worth it, but you will get all
> the precision you want without any nasty "Inf" results
Is the OP still here? I was curious what end result you were
after and if you tried any of these approaches. Apparently the quantity
here is something like 5000 which could probably itself
be an intermediate. If you took the approach of using algebra, as suggested
by earlier posters, and your
end result was supposed to be between 0 and 1, there would probably be
more simplifications to make. IIRC, you had terms like
n!(2n!)
---------------------------
k!(n-k)!(600-k)!(2n-600+k)!
and you could cancel a lot ahead of time. You'd think
somewhere, like in statistical mechanics, this would be a well known
issue.
> :-)
> Carl
More information about the R-help
mailing list