Jose Ramon
Jose Ramon

Reputation: 5444

Calculate randomly integers within a range in python

I want to calculate 5000 random integers between a range 0-50000 for example. I do so using the following code in python:

np.random.seed(0)
ind = np.random.randint(TOTAL_SIZE, size=(5000,)) //TOTAL_SIZE = 50.000

How can I store the rest integers. I tried something like ~ind but did not work.

Upvotes: 1

Views: 102

Answers (1)

Mihai Alexandru-Ionut
Mihai Alexandru-Ionut

Reputation: 48337

You can use a list comprehension.

rest = np.array([i for i in range(0,50000) if i not in ind])

Upvotes: 1

Related Questions