Skip to content

Instantly share code, notes, and snippets.

View Ram-N's full-sized avatar

Ram Narasimhan Ram-N

View GitHub Profile
@Ram-N
Ram-N / equi_buckets.R
Last active January 7, 2021 21:50
Slice a skewed distribution into buckets with equal populations
#' num_bkts should be a non-zero integer
#' col should contain numeric values
equi_bucket <- function(col, num_bkts){
if(!is.numeric(col)){
warning("Values passed to Equibucket are not numeric")
return(NA)
}
xmin = min(col, na.rm = TRUE)
eps = 1/(num_bkts-1)