PageRenderTime 82ms CodeModel.GetById 40ms app.highlight 2ms RepoModel.GetById 39ms app.codeStats 0ms

/fingerprint/R/bitimp.R

http://github.com/rajarshi/cdkr
R | 13 lines | 11 code | 2 blank | 0 comment | 0 complexity | 2c642bc1f05561df93d2c76a9fae1748 MD5 | raw file
 1bit.importance <- function(actives, background) {
 2  bs.actives <- bit.spectrum(actives)
 3  bs.background <- bit.spectrum(background)
 4
 5  m <- length(actives)
 6  n <- length(background)
 7  pa <- (m*bs.actives+bs.background)/(m+1)
 8  pb <- (n*bs.background+bs.actives)/(n+1)
 9
10  kl <- pa * log(pa/pb) + (1-pa) * log( (1-pa)/(1-pb) )
11  kl[is.nan(kl)] <- NA
12  return(kl)
13}