Equal-Frequency Binning with Ties
~12 mincode completion
Implement quantile_bins(x, n_bins) returning the integer bin index of every value, in the original order.
Where this shows up
~12 min
••••••••••••••••
8 employers weight this skill
3 big tech firms, 2 AI product companies, 1 defense company, 1 enterprise vendor, 1 quant fund. Top match scores 87.
Python
import numpy as np
def quantile_bins(x, n_bins):
"""
Equal-frequency bin index for every value, ties sharing a bin.
Args:
x: array of shape (n,)
n_bins: number of bins B
Returns:
integer array of shape (n,): floor(B * r_i / n), where r_i counts
the values strictly smaller than x_i
"""
# YOUR CODE HERE
pass