dear All,
i'm using the following two functions:
share.vector <- function (vec1)
{
vec1 <- vec1 - max(vec1,na.rm=TRUE) -0.1 ## this line avoids overflow
vec1 <- exp(vec1)
vec2 <- vec1/(1+sum(vec1,na.rm=TRUE))
vec2
}
share.matrix <- function (mat1)
{
out1 <- apply(mat1,2,share.vector)
return(out1)
}
vec1 is a vector (of numeric data, usually small numbers), mat1 is a matrix
with many vec1's
is there another way to program them such that they are more efficient (in
terms of time)?
i appreciate any hints or advice.
best regards,
Carlos
[[alternative HTML version deleted]]