def sample(A, N):
    population = np.zeros(sum(A))
counter = 0
for i, x in enumerate(A):
    for j in range(x):
        population[counter] = i
counter += 1
sampling = population[np.random.randint(0, len(population), N)]
return np.histogram(sampling, bins=np.arange(len(A) + 1))[0]
Down-sampling with numpy