search for: calsta

Displaying 2 results from an estimated 2 matches for "calsta".

2011 Feb 12
1
how to improve the precison of this calculation?
..."result", this is just a picture of the calculation which can't implement due to the precision problem i<-0:(c-1) vec<-choose(n,i)*choose(NT-n,CT-i) #get the vector which need summation result<-log(sum(vec)) #get the log of summation # thanks to Petr, we have a solution calsta <- function(c, n) { i <- seq(from=0, length=c) logx <- lchoose(NT-n, CT-i) + lchoose(n, i) logmax <- max(logx) logmax + log(sum(exp(logx - logmax))) } # now, new problem arise, in theory, the "result" of different (c,n) pair should most probably differ, so I can order t...
2011 Feb 11
3
How can we make a vector call a function element-wise efficiently?
Hello I have a time-comsuming program which need to simplify, I have tested the annotated program as follow: > #define function which will be call > calsta <- function(c, n=100000) + { + i <- seq(from=0, length=c) + logx <- lchoose(NT-n, CT-i) + lchoose(n, i) + logmax <- max(logx) + logmax + log(sum(exp(logx - logmax))) + } > CT=6000 #assignment to CT > NT=29535210 #assignment to NT > > vec<-c(2331,524,918,21...