I am trying to apply conditional statements in a numpy array and to get a boolean array with 1 and 0 values.
I tried so far the np.where(), but it allows only 3 arguments and in my case I have some more.
I first create the array randomly:
numbers = np.random.uniform(1,100,5)
Now, if the value is lower then 30, I would like to get a 0. If the value is greater than 70, I would like to get 1. And if the value is between 30 and 70, I would like to get a random number between 0 and 1. If this number is greater than 0.5, then the value from the array should get 1 as a boolean value and in other case 0. I guess this is made again with the np.random function, but I dont know how to apply all of the arguments.
If the input array is:
[10,40,50,60,90]
Then the expected output should be:
[0,1,0,1,1]
where the three values in the middle are randomly distributed so they can differ when making multiple tests.
Thank you in advance!