INNER CODE UNIT · C++
rU
GreenleafLab/chromVAR · src/utils.cpp:72
rU = unif_rand() * nOrig;
kk = (int) rU;
index[ii] = (rU < prob[kk]) ? kk : alias_tab[kk];
}
return index + 1;
}
//Helper Function for background sampler
// [[Rcpp::export]]
arma::umat bg_sample_helper(arma::uvec bin_membership, arma::mat bin_p,
arma::vec bin_density, arma::uword niterations){
arma::uword n = bin_membership.n_elem;
arma::umat out = arma::umat(n, niterations);
for (arma::uword i = 0; i < bin_density.n_elem; i++){
arma::uvec ix = find(bin_membership == i);
arma::vec p_tmp = bin_p.col(i);