Question: use Matlab language to write 234 2. Write a function wrand(w) which takes as input a (given) real number between 0 and 1 and as

 use Matlab language to write 234 2. Write a function wrand(w)use Matlab language to write 234

2. Write a function wrand(w) which takes as input a (given) real number between 0 and 1 and as output returns 1 with probability w and returns -1 with probability (1 - w). 3. Write a "weighted" random walk function walkn, w) which continues up to integer point n from the origin and where the steps are taken by calling the wrand(w) function (so, the step is either 1 or -1). For example, if you ruming function(v] = rwalk(4, -75), the output may ended by 4 as v=[ 0 -1 0 1 2 1 2 10 1 2 3 4] or ended by -4 as v=[0 1 2 1 0 -1 0-1 0 -1 -2 -1 -2 -3 4]. 4. In a script called myscript.m, call 10,000 times the function rwalk(10, 0.55). Use these calling to estimate the probability that the vector (v) ends at 10. Indeed, by each calling rwalk/10, 0.55) the vector (v) ends either at 10 or -10. But we need to take the sum of those that ended by 10. Save that probability with the variable name p10 in the end of this script. Also use this script to estimate the expected length of such a random walk. Save this expected length with the variable name e10 in the end of this script. It is necessary to start your script with the command "clear" 2. Write a function wrand(w) which takes as input a (given) real number between 0 and 1 and as output returns 1 with probability w and returns -1 with probability (1 - w). 3. Write a "weighted" random walk function walkn, w) which continues up to integer point n from the origin and where the steps are taken by calling the wrand(w) function (so, the step is either 1 or -1). For example, if you ruming function(v] = rwalk(4, -75), the output may ended by 4 as v=[ 0 -1 0 1 2 1 2 10 1 2 3 4] or ended by -4 as v=[0 1 2 1 0 -1 0-1 0 -1 -2 -1 -2 -3 4]. 4. In a script called myscript.m, call 10,000 times the function rwalk(10, 0.55). Use these calling to estimate the probability that the vector (v) ends at 10. Indeed, by each calling rwalk/10, 0.55) the vector (v) ends either at 10 or -10. But we need to take the sum of those that ended by 10. Save that probability with the variable name p10 in the end of this script. Also use this script to estimate the expected length of such a random walk. Save this expected length with the variable name e10 in the end of this script. It is necessary to start your script with the command "clear

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 Databases Questions!