Home > Enterprise >  Create two arrays in numpy with random int from a uniform distr
Create two arrays in numpy with random int from a uniform distr

Time:10-22

Each number in "a" array should be >= with the number in the same position from "b" array. Range 0,10

a = np.random.randint(0,10,300)

b=[]
for i in a:
   b = np.random.randint(0,i,300)

Got a ValueError: low >= high

Then I tried i 1 but values in b exceed the ones from a

CodePudding user response:

If your goal is to create two random arrays ensuring a >= b, you can use:

b, a = np.sort(np.random.randint(0, 10, (2, 300)), axis=0)

assert (a>=b).all()
  • Related