Wednesday, 2 October 2013

Best way to iterate 1 to 10 times and add value and to numpy array in python

Best way to iterate 1 to 10 times and add value and to numpy array in python

I know this is a simple question for someone, but I'm lost here.
Say if I want my result to be 10 random numbers in an array value:
np.random.randint(0,2) # returns 0,1
I want to iterate 10 times:
for i=1 to 10 :
np.random.randint(0,2) addto myarray
I want a numpy array of0,1,1,0... 10 times
Thank you.

No comments:

Post a Comment