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

Run your code to see results

⌘↵ runs against the visible tests

Loading docs…

The AI Mentor needs an account

It reads your code and the failing tests and nudges you toward the fix without handing you the answer. Free accounts get it on every problem you're working on today.