I'm doing stastitics on cointossing. I need a N number of values to be either 0 or 1 based on random numbers.
My code:
import numpy as np
x = np.random.rand(10)
for i in x:
if i < 0.5:
i == 0
elif i >= 0.5:
i == 1
print(x)
The code still returns a vector of 10 random numbers between 0 and 1. How can i change my code so it returns a vector of N number of 0 and 1 based on the random vector?
Aucun commentaire:
Enregistrer un commentaire