Generating evenly distributed multiples/samples within a range

前端 未结 5 1734
说谎
说谎 2020-12-21 05:47

Specific instance of Problem
I have an int range from 1-100. I want to generate n total numbers within this range that are as evenly distributed

5条回答
  •  忘掉有多难
    2020-12-21 06:17

    Extra dependency and maybe overkill, but short, tested and should give correct results: numpy.linspace

    >>> numpy.linspace(1, 100, 4).astype(int).tolist()
    [1, 34, 67, 100]
    

提交回复
热议问题