The modified function I presented contains a stupid error, which is
corrected below.
sum1 <- function(l,u,t,i,n,w,tol=.Machine$double.xmin) {
v <- 0
v2 <- 1
for (m in 0 :w & v2 > tol) {
v1 <- ((u^(1/2))*(l^(1/2))*t)^(i-n+2*m)
v2 <- exp(-lgamma(i-n+m+1)-lgamma(m+1))
v3 <- v1*v2
v <- v+v3
}
re
ate University of New York
1021 Main Street
Buffalo, NY 14203-1016
Office: 716-887-6807
Fax: 716-887-2510
http://www.ria.buffalo.edu/profiles/lucke.html
molinar
Sent by: r-help-boun...@r-project.org
04/23/2009 10:00 AM
To
r-help@r-project.org
cc
Subject
Re: [R] large factorial
One more improvement. Perhaps it would be best just to return a numeric
so sum1 inputs and outputs numerics:
library(rSymPy)
# define factorial to return a Sym object
factorial.Sym <- function(n) Sym("factorial(", n, ")")
sum1 <- function(l,u,t,i,n,w) {
v <- 0
for (m in 0 :w) {
v1 <-
The code in my prior post works (except one comment was wrong)
but try this instead. The only change is the last line of the sum1
function. This way it produces a Sym object rather than a character
string.
library(rSymPy)
# define factorial to return a Sym object
factorial.Sym <- function(n) S
sympy() returns a character string, not an R numeric -- it shouldn't
automatically return an R numeric since R can't represent all
the numbers that sympy can.
The development version of rSymPy has a second class which
produces objects of class c("Sym", "character") and those
can be manipulated wit
[mailto:r-help-boun...@r-project.org] On
Behalf Of molinar
Sent: Thursday, April 23, 2009 9:42 AM
To: r-help@r-project.org
Subject: Re: [R] large factorials
Thank you everyone all of your posts were very helpful. I tried each one
and I think I have about 10 new packages installed. The formula I
Here is what I did:
library(rSymPy)
factorial.sympy <- function(n) sympy(paste("factorial(", n, ")"))
factorial.sympy(171)
[1]
"1241018070217667823424840524103103992616605577501693185388951803611996075221691752992751978120487585576464959501670387052809889858690710767331242032218484364310473577889
Thank you everyone all of your posts were very helpful. I tried each one and
I think I have about 10 new packages installed. The formula I need to
calculate did not involve any logarithms but infinite summations of
factorials, I'm sorry for not specifying. I read some things about using
logarit
Also the R sympy package can handle this:
> library(rSymPy)
Loading required package: rJava
> factorial.sympy <- function(n) sympy(paste("factorial(", n, ")"))
> # note that first time sympy is called it loads java, jython and sympy
> # but on subsequent calls its faster. So make a dummy call f
a clear
>> description of what you're trying to do and someone may be able
>> to help.
>>
>> Murray M Cooper, Ph.D.
>> Richland Statistics
>> 9800 N 24th St
>> Richland, MI, USA 49083
>> Mail: richs...@earth
J Dougherty wrote:
> On Wednesday 22 April 2009 12:21:41 pm molinar wrote:
>
>> I am working on a project that requires me to do very large factorial
>> evaluations. On R the built in factorial function and the one I created
>> both are not able to do factorials over 170. The first gives an er
J Dougherty wrote:
>
> If you need an open source arbitrary precision calculator, you might want
> to
> look at Octave which is OS and works similarly to Mathematica - up to a
> point
> books for Mathematica will be a significant help with Octave.
>
> JDougherty
>
>
??? octave is a Ma
On Wednesday 22 April 2009 12:21:41 pm molinar wrote:
> I am working on a project that requires me to do very large factorial
> evaluations. On R the built in factorial function and the one I created
> both are not able to do factorials over 170. The first gives an error and
> mine return Inf.
>
.
>
> Murray M Cooper, Ph.D.
> Richland Statistics
> 9800 N 24th St
> Richland, MI, USA 49083
> Mail: richs...@earthlink.net
>
> - Original Message - From: "molinar"
> To:
> Sent: Wednesday, April 22, 2009 3:21 PM
> Subject: [R] large factorials
t
- Original Message -
From: "molinar"
To:
Sent: Wednesday, April 22, 2009 3:21 PM
Subject: [R] large factorials
I am working on a project that requires me to do very large factorial
evaluations. On R the built in factorial function and the one I created
both are not a
I am working on a project that requires me to do very large factorial
evaluations. On R the built in factorial function and the one I created
both are not able to do factorials over 170. The first gives an error and
mine return Inf.
Is there a way to have R do these larger calculations (the c
16 matches
Mail list logo