I would like to get a random floating-point value between -2 and +2. The best I could do is:
my_array = [-1, 1]
change_sign = []
for i in range(6):
change_sign.append(my_array[np.random.randint(low=0, high=2)] * 2)
print(change_sign)
results = np.random.random([6]) * change_sign
Desired output:
[-1.14, -0.25, 0.33, 1.75, 1.99, -0.83]
But I feel like it could be done even more easily. I don't want to use other numpy methods (like uniform), just random and randint.
How could I do that ?