vendredi 30 novembre 2018

How to generate random numbers with each random number having a difference of atleast x with all other elements?

I know this goes against the definition of random numbers, but still I require this for my project. For instance, I want to generate an array with 5 random elements in the range[0, 200].

Now, I want each of the elements to have a difference of atleast 15 between them. So the random array should look something like: [15, 45, 99, 132, 199]

I can generate random numbers using numpy: np.random.uniform(low=0, high=200, size=5)

Thanks in advance.

However, I am not able to keep a consistent difference of atleast 15.




Aucun commentaire:

Enregistrer un commentaire