Hi all,
   I wrote the following code for the function that is attached.
I want to simply the code. Can some one give me some help?


The function is attached and the following is the code:
####################################################################
## f1 is the function calculate the value outside the sum
f1 <- function(t, a, b) {t/beta(a, b)}
## f2 is the function that calculates the summand
f2 <- function(j, k, t, a, b){choose(j-1,k-1)*(1-t)^(j-1) * beta(a+k, b+j-
k)}
## f3 calculates the sum
f3 <- function(n, t, a, b){
ss <- matrix(0, nrow=n, ncol=n)
for (j in 1:n){
    for (i in 1:j) {
            ss[i,j]<- f2(j,i, t, a, b)
                    }
                }
sum <- sum(ss)
return(sum)
}
## f is the final function
f <- function(n,t, a, b) {f1(t,a ,b)*f3(n,t,a,b)}

##########################################################################

   Many thanks!








                             Hannah

Attachment: question to R-heip.pdf
Description: Adobe PDF document

______________________________________________
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.

Reply via email to