Skip to content

Instantly share code, notes, and snippets.

View dickoa's full-sized avatar

Ahmadou Dicko dickoa

View GitHub Profile
@dickoa
dickoa / up_brewer.R
Last active August 27, 2023 16:31
Brewer method unequal probabilities speed up
up_brewer <- function(pik, eps = 1e-06) {
if (any(is.na(pik)))
stop("there are missing values in the pik vector")
list <- pik > eps & pik < 1 - eps
pikb <- pik[list]
s <- pik
N <- as.integer(length(pikb))
sb <- vector(mode = "double", length = N)
r <- .C("C_up_brewer", pikb, N, result = sb)
s[list] <- r$result