Long number operations in R
I am trying to use maximum likelihood methods (usually around 10 ^ 5 iterations) with a probability distribution that produces very large integers and very small floating point values โโthat cannot be stored as numeric
or in a type float
.
I thought I was using as.bigq
in a package gmp
. My problem is that two objects of a class / type can be added, subtracted, multiplied and immersed bigq
, while my distribution actually contains logarithmic, energy, gamma and confluent hypergeometric functions.
What's my best option for solving this problem?
- Should I use a different package?
- Should I code all these functions for objects
bigq
.- Coding these functions in R can make some functions very slow, right?
- How do I write a logarithm function using only operators
+,-,*,/
? Should I approximate this function with taylor series extension? - How do I write a cardinality function using only operators
+,-,*,/
when the exponent is not an integer? - How do I write a collapsed hypergeometric function (equivalent to function
Hypergeometric1F1Regularized[..]
inMathematica
)?
I could end up writing these functions in C
and calling them from R
, but that sounds like some tricky work for not much, especially if I have to use a package gmp
in C and also handle those large numbers.
source to share
All your problems can be solved with Rmpfr
, most likely, which allows you to use all the functions returned with any precision getGroupMembers("Math")
.
Vignette: http://cran.r-project.org/web/packages/Rmpfr/vignettes/Rmpfr-pkg.pdf
A simple example of what it can do:
test <- mpfr(rnorm(100,mean=0,sd=.0001), 240)
Reduce("*", test)
I DON'T THINK it has hypergeometric functions though ...
source to share