R/table-weights.R

Defines functions get_weights_from_table

Documented in get_weights_from_table

## SKG
## February 26, 2020
## Getting importance sampling to work based on empirical distributions


#' Get empirical weights from a pre-computed table
#'
#' @param n cluster size
#' @param x number of positive smears in the cluster
#' @param number of positive transmissions
#' @param tab_list list of tables with pre-computed probabilities
#' @return probability of i positive given n,x
get_weights_from_table <-  function(n, x, i_pos,
                                    tab_list = TBornotTB::idistrib1e4){

 # browser()
  tab <- tab_list[[n]][x + 1,]
  probs <- tab[i_pos + 1] / sum(tab)
  return(probs)

}
skgallagher/TBornotTB documentation built on April 21, 2020, 1:19 p.m.