Question: Let pN(n) be the probability that an N-step walk ends at position n. Some examples for small n: Po(0) = 1 p(1) = p(1)
Let pN(n) be the probability that an N-step walk ends at position n. Some examples for small n: Po(0) = 1 p(1) = p(1) = // P2(2) = P2(2) = 1; P2(0) = // P3(3) = 3(3) = {}; P3(1) = P3(1) = Generally, PN(n) depends on the number of ways of ending at position n. For example, where n = 3, there is one way to end at positions -3 and 3, and three ways to end at positions 1 and 1 (ways to reach position 1: 0, 1, 0, 1, or 0, 1, 0, 1, or 0, 1, 2, 1). [As an aside, the number of N-step walks ending at position a - b is given by the binomial coefficients of (a + b). For N = 4, we have (a + b) = a + 4ab + 6ab + 4ab + b4. The coefficient () gives us the number of ways of ending at a - b where a counts as an increment (to the right) in the walk and b as a decrement (to the left).] For this problem, write count_random_walks(N, nbr_tries) that returns a dictionary that maps n to the number of N-step walks that ended at n, out of a total of nbr_tries many walks. For example (note your result will probably vary slightly from this): counts = count_random_walks (3, 10000) for c, v in counts.items (): print (f'{c}: {v}') -3: 1227 3: 1251 -1: 3766 1: 3756
Step by Step Solution
3.51 Rating (141 Votes )
There are 3 Steps involved in it
The compl... View full answer
Get step-by-step solutions from verified subject matter experts
