import math


def get_frequencies_bivariate(sample, mn, mx, bins):
    """
    Computes the frequencies of a bounded bivariate sample.
    :param sample: (List((Float,Float)) array of bivariate sample values.
    :param mn: (Float) the lower bound.
    :param mx: (Float) the upper bound.
    :param bins: (Int) the number of bins to divide the interval into.
    :return: (List[Int]) the list of frequencies in bins.
    """

    frequencies = []
    interval = mx - mn
    binsize = interval / bins

    for bin1 in range(0, bins):
        frequencies.append([])
        for bin2 in range(0, bins):
            frequencies[bin1].append(0)

    for values in sample:
        bin1 = int(math.floor(values[0] / binsize))
        bin2 = int(math.floor(values[1] / binsize))
        frequencies[bin1][bin2] += 1

    return frequencies