Pstat160Winter 2009Homework #6, Matlab partDue: Monday, March 9thProblem 1. Random walksFor this problem, you will need the functions randwalk.m, rwpb.m and rwcount.m. Recall that for any functionsthat gives both outputs and graphs, if you want to see only the graph put a semicolon; after you call this function,without setting a variable for it. For instance, X=randwalk(100,.5); return a graph and all 100 values of the randomwalk, whereas randwalk(100,.5); returns only the graph. Don’t forget the semicolon if you don’t want all 100 valueson your screen!a) Simulate a random walk using the function randwalk.m. Explain briefly the program. Usep=.5, p=.4, p=.6andn= 20, n= 100, n= 500. Do several runs for each values, and explain. Return only a couple a figures!b) Here we want to test that the theoretical and empirical values for the probability after n steps agree. Use thefunction rwcount.m for that purpose. Explain briefly the idea of this program. Try forn= 10, p=.5 andk= 20,100or 500. Explain. Now changento be 40, for the same values of k. Can you see any difference and why?
This is the end of the preview.
access the rest of the document.
Stochastic process, Markov chain, Random walk, random walks