I have a list of numbers and I would like to select n values evenly distributed across the list.
For example:
vals = list(range(10))
select_n(vals, 4)
select_n(vals, 5)
should give
[0, 3, 6, 9]
[0, 2, 5, 7, 9]
My current hack is to iterate as such:
[vals[round((len(vals) - 1)/(n-1) * i)] for i in range(n)]
Is there a Python or NumPy function to do this? If not, is there a more efficient way to write this?