As already noted, randn produces a normally distributed number (aka Gaussian). To get an even distribution, you must use a โuniformโ.
If you need only one sample at a time in 10 evenly distributed numbers, you can use:
import numpy as np x = np.random.uniform(low=-1,high=1,size=10)
OR if you want to generate lots (for example, 100) from them immediately, you can do:
import numpy as np X = np.random.uniform(low=-1,high=1,size=(100,10))
Now X [0], X [1], ... each has a length of 10.
source share