TABLE OF CONTENTS
CmakeLikelihood/LikelihoodFrailtyLogSum [ Functions ]
NAME
LikelihoodFrailtyLogSum --- utility to efficiently compute a sum of log-frailties
FUNCTION
Because the log function is quite slow (especially it seems on the MacIntel architecture), this function computes the sum of log-frailties by multiplying several together at a time, then taking logs.
SYNOPSIS
1648 static inline double LikelihoodFrailtyLogSum(int nx, double *Y)
INPUTS
nx number of observations Y vector of length nx
OUTPUTS
lik sum of log(Y)
SOURCE
1652 { 1653 double lik=0; 1654 double thislik = 1; 1655 1656 for(int i=0; i<nx; i++) { 1657 thislik *= Y[i]; 1658 if(i % LIK_MOD == 0){ 1659 lik += log(thislik); 1660 thislik = 1; 1661 } 1662 } 1663 lik += log(thislik); 1664 return lik; 1665 }