deps/kb_meme/meme-5.0.1/src/tomtom.c
/**************************************************************************
 * Likelihood of the data, given a Dirichlet component.
 *
 * This is the final equation on p. 13 of Habib et al.
 **************************************************************************/
Likelihood of the data, given a Dirichlet component.
This is the final equation on p. 13 of Habib et al.
Likelihood of the data given a Dirichlet component . This is the final equation on p . 13 of Habib et al .
static double compute_log_likelihood (int hypers[], ARRAY_T* counts) {
  double hyper_sum = 0.0;
  double count_sum = 0.0;
  int i_alph;
  int alphabet_size = get_array_length(counts);
  for (i_alph = 0; i_alph < alphabet_size; i_alph++) {
    hyper_sum += (float)(hypers[i_alph]);
    count_sum += get_array_item(i_alph, counts);
  }
  double log_likelihood = lgamma(hyper_sum)- lgamma(count_sum+hyper_sum);
  for (i_alph = 0; i_alph < alphabet_size; i_alph++) {
    double hyper = (float)(hypers[i_alph]);
    double count = get_array_item(i_alph, counts);
    log_likelihood += lgamma(hyper + count) - lgamma(hyper);
  }
  return(log_likelihood);
}
static double compute_log_likelihood ( int hypers [ ] , ARRAY_T * counts ) { double hyper_sum = 0.0 ; double count_sum = 0.0 ; int i_alph ; int alphabet_size = get_array_length ( counts ) ; for ( i_alph = 0 ; i_alph < alphabet_size ; i_alph ++ ) { hyper_sum += ( float ) ( hypers [ i_alph ] ) ; count_sum += get_array_item ( i_alph , counts ) ; } double log_likelihood = lgamma ( hyper_sum ) - lgamma ( count_sum + hyper_sum ) ; for ( i_alph = 0 ; i_alph < alphabet_size ; i_alph ++ ) { double hyper = ( float ) ( hypers [ i_alph ] ) ; double count = get_array_item ( i_alph , counts ) ; log_likelihood += lgamma ( hyper + count ) - lgamma ( hyper ) ; } return ( log_likelihood ) ; }
Likelihood of the data, given a Dirichlet component.
Likelihood of the data given a Dirichlet component .
// Sum the counts and the hyperparameters. // Compute the log of likelihood.