Question: Given a simple symmetric random walk (S n) 20 with So = 0, we define the following random variables: 0 The total number of periods

 Given a simple symmetric random walk (S n) "20 with So= 0, we define the following random variables: 0 The total number

Given a simple symmetric random walk (S n) "20 with So = 0, we define the following random variables: 0 The total number of periods from 0 to 2N the random walk spends above zero: CZN = |{n e {1, ...,2N} :8\" > on. . The time of the last visit to 0 before time 2N: L2N=max{05n52N:Sn=0}. . The time when the random walk reaches its maximum value between time 0 and 2N: MzN = argmax{S,, :0 S n S 2N}. Problem 2 (6 points) Write three functions which take a path (= realization) of the random walk as an input and then compute a value (= realization) of the random variables C2N, L2N, M2N, respectively, as defined above. 1. Function: timeAboveZero(...) Input: . path: Realization of the random walk from the function randomWalk(2N) Output: . result: Realization of the random variable C2N In [ ]: def timeAboveZero(path): ## WRITE YOUR OWN CODE HERE ## HINT: USE numpy.sum() AND A LOGICAL OPERATION return result In [ ]: ## TEST YOUR FUNCTION HERE path = randomWalk(20) print(path) timeAboveZero(path)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Mathematics Questions!