def findMode_Mult_1D(N, w):
    w = np.asarray(w, dtype=np.float64)
    n = np.floor( N * w)
    f = N * w - n
    q = (1 - f)/ w
    while n.sum() < N:
        minID = np.argmin(q)
        n[minID] += 1
        if n.sum() < N:
            q[minID] += 1/w[minID]            
    assert np.abs(n.sum() - N) < 0.0001
    return n
dataset/ETHPy150Open daeilkim/refinery/refinery/bnpy/bnpy-dev/bnpy/util/NumericHardUtil.py/findMode_Mult_1D/original