python - How can I generate a pseudo-random list of 1s and -1s? -
i want generate pseudo-random list of 10 numbers seeded seed. want list has 1s , -1s , probability of each 1 0.5.
import numpy np np.random.seed(0) np.random.randint(2, size=(10,))
i don´t distribution of 1s , -1s, of 1s , 0s... , don´t know if probability of each number 1/2.
any clue?
as @jtbandes said, np.random.choice
function help:
import numpy np np.random.seed(0) np.random.choice([-1,1], size=(10,))
Comments
Post a Comment