I have a numpy.array with several integer values.
For all values from 0 to the maximal value in the array, I want to count how many elements are equal or greater.
This is my current code:
import numpy as np
from random import randint
arr = np.array([randint(0, 10) for _ in range(20)])
val_range = np.arange(arr.max() + 1)
count_array = np.array([(arr >= v).sum() for v in val_range])
Is there a better way implementing this with numpy?
I want to implement this with numpy and later integrate the code in a function compiled with numba.