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 } return(v) } sum1(1,2,10,80,3,80) [1] 5.519201e-23 > sum1(1,2,10,80,3,100) [1] 6.892307e-23 > sum1(1,2,10,80,3,200) [1] 1.375784e-22 > sum1(1,2,10,80,3,1000) [1] 6.86821e-22 Need more coffee... Joseph F. Lucke Senior Statistician Research Institute on Addictions University at Buffalo State 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 [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.