Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribeduse 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals Design And Implementation

Authors: KROENKE DAVID M.

1st Edition

8120322258, 978-8120322257

More Books

Students also viewed these Databases questions

Question

What is an effective transfer?

Answered: 1 week ago