Question: Problem 2 (9 Points) Write three functions which take a path (= realization) of the random walk as an input and then compute a value

Problem 2 (9 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 CON 12N 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 CON In [ ] : def timeAbovezero (path) ! I 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 ) 2. Function: TimeOfLastVisitOfzero( . . . ) Input: path: Realization of the random walk from the function randomwalk ( 2N ) Output: result: Realization of the random variable L2N In [ ]: def TimeofLastVisitofzero[path) : I WRITE YOUR OWN CODE HERE #" HINT: USE numpy . where () AND sumpy . amax( ) return lastVisit In [ ]: # TEST YOUR FUNCTION HERE path = randomWalk(20) print [path) TimeOfLastVisitofzero(path) 3. Function: timeHitMax ( . . . ) Input: path: Realization of the random walk from the function randomwalk ( 2N ) Output: result: Realization of the random variable MIN In [ ] : def timeHitHax ( randomwalk) ! WRITE YOUR OWN CODE HERE #8 HINT! USE Jumpy . argmax( ) return result In [ ]: # TEST YOUR FUNCTION HERE path - randomwalk ( 20) print [path) timelitMax (path)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
