Feb-04-2018, 06:23 PM
Hi,
I don't need any help coding anything I just really am confused on this code:
It prints out: [0, 0, 1, 1, 1, 1, 1, 1, 2, 3, 3]
Supposedly this is an example of somehing called a "random walk"
I am a little confused on the tails.append line and the output. I am confused on why there are 11 items and how this manages to ignore the heads aspect. It only tracks tails. I didn't find the video very clear at all.
Thanks
I don't need any help coding anything I just really am confused on this code:
1 2 3 4 5 6 7 |
import numpy as np np.random.seed( 123 ) tails = [ 0 ] for x in range ( 10 ) : coin = np.random.randint( 0 , 2 ) tails.append(tails[x] + coin) print (tails) |
Supposedly this is an example of somehing called a "random walk"
I am a little confused on the tails.append line and the output. I am confused on why there are 11 items and how this manages to ignore the heads aspect. It only tracks tails. I didn't find the video very clear at all.
Thanks