Question
Please Solve this question by using Matlab.
errors accumulate ran 1.1.6. Its reasonable to expect that floating point during a long computation, creating what is known as a random walk. O average we expect as many errors to be negative as positive, so they tend to partially cancel out. Suppose we define a random sequence by x 0 and 4-1 ± 1 for n 1, with the signs chosen by tossing a fair coin for each n. Let a, and B, be the average values of x, and I.,), respectively, over all such waks Then a classic result of probability is that a, 0 and (a) In MATLAB the function randn simulates drawing numbers from the normal or Gaussian distribution G.e., the bell curve) with mean zero and variance 1. Choose a unique positive integer seed value s (for example, use the last 5 digits of your phone number) and enter rng(s) to initialize the random number generator. Then the following code generates one random walk for n 10: r randn (10000,1); % draw random numbers % cumulative summation cunsum(sign(r)); We can plot every fifth number in the sequence using plot(x(1:5:end)), hold on Plot 50 such random walks all together on one graph. x (b) Perform a million random walks, computing the average values oft oe /2n/r at n-: 10000. and mooool. Compare these to α ~O and ß
0 0
Add a comment Improve this question Transcribed image text
Answer #1

clear
%a
for i=1:50
r=randn(10000,1);
x=cumsum(sign(r));
plot(x(1:5:end)),hold on
end
%b
xn=zeros(1,1000000);
xn_abs=xn;
for i=1:1000000
r=randn(10000,1);
x=cumsum(sign(r));
xn(i)=x(end);
xn_abs(i)=abs(x(end));
end
fprintf('average of x(10000): %f\n',mean(xn))
fprintf('average of |x(10000)|: %f\n',mean(xn_abs))
fprintf('Bn: %f\n',sqrt(2*10000/pi))
fprintf('an=0\n')

Command Window MAT EDITOR PUBLISH > randomwa average of x(10000): 0.014472 average of x (10000) 79.693844 Bn: 79.788456 an-0>> Find Files New Open Save Compare ▼ Go To▼ D Breakpoints Run Run and Print Find Advance ▼ FILE NAVIGATE Figure 1 1clear File Edit View Tools Desktop Window Help 3- El for i=1 : 50 r=randn (10000,1) ; x-cumsum (sign (r)); plot (x (1:5:end)) , hold on 250 end 200 9-xn-zeros (1, 1000000) abs=xn ; 10- xn 150 11-for i-1:1000000 r=randn (10000,1) ; x-cumsum (sign (r)) xn (i)-x (end); xn abs (i)-abs (x(end) ); 100 13- 14 15- 16 - 17- fprintf ( average of x(10000): %f\n,mean (xn)) 18- fprintf ( averageoflx ( 10000)I:%f\n,mean/xn 19- tprintf (Bn: %f\n, sart (2*10000/pi)) 20fprintf (an-0 n) 50 end abs )) -50 100 -150 200 0 200 400 600 800 1000 1200 1400 1600 1800 2000

Add a comment
Know the answer?
Add Answer to:
Please Solve this question by using Matlab. errors accumulate ran 1.1.6. It's reasonable to expect that...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • We will be using Matlab as the software tool for this lab project. 1.Explore and become...

    We will be using Matlab as the software tool for this lab project. 1.Explore and become familiar with the random number generators in Matlab such as “rand”, “randn”, and “randi” (in fact all software tools can only generate pseudo-random numbers). Notice that to randomize the generators the use of “rng” function is encouraged as the previous techniques are discouraged. 2. “Random walk” is one of the primary and relative simple random processes in which the process starts from a neutral...

  • Implement the following problems in MATLAB and document your work using the report guidelines on ...

    Implement the following problems in MATLAB and document your work using the report guidelines on the next page. 1. Use the subplot function to place the relevant graphical results in a single figure. Generate a sequence of 1000 pairs of independent zero-mean Gaussian random variables, where X has variance 2 and N has variance 1, Let Y = X + N be the equation for a noisy signal. Plot X, N, and Y in a 3D scatter plot using Y...

  • solve with only matlab, please. :) random 15.8 Ifr is a normal random number with mean...

    solve with only matlab, please. :) random 15.8 Ifr is a normal random number with mean 0 and variance 1 (as generated by randn), it can be transformed into a random number X with mean u and standard deviation a by the relation X=ar + In an experiment, a Geiger counter is used to count the radioactive emissions of cobalt 60 over a 10-second period. After a large number of such readings are taken, the count rate is estimated to...

  • need help with matLab Question 1 (20 Points) Write a well-documented MATLAB script hmwk7Q1.m that simulates...

    need help with matLab Question 1 (20 Points) Write a well-documented MATLAB script hmwk7Q1.m that simulates tossing 100 coins into a unit square. As shown in the scatter plot. Location of Simulated Coins In Unit Square 1 o0 Ooo 05 04 03 02 oo 0.1 2 03 4 05 07 1 xpostion Hmwk7Q1.fig Consider organizing your MATLAB script into the following sections. % housekeeping (performs clearing of figures, workspace, and command lines) % Initialize the Number of Coins To Simulate...

  • solve using MatLab please. HW - 1 Use a cover page Word file attached for the...

    solve using MatLab please. HW - 1 Use a cover page Word file attached for the homework solution. Solve all questions using Word and the Matlab output should be copied into the Word file. All questions and answers should be numbered HW1.1 Generate the following sequences using the basic MATLAB signal functions and the basic MATLAB signal operations discussed in this chapter. Plot signal samples using the stem function. 1- x(n) = n°[u(n+5] – u(n-6) + 105(n) + 20(0.5)* [u(n-4)...

  • matlab and comment please only need (D) In this exercise we learn how to solve constant-coefficient...

    matlab and comment please only need (D) In this exercise we learn how to solve constant-coefficient difference equation using Mat lab. Also, we investigate the response of systems to different kinds of inputs. (1) Consider the difference equation given as follows: y(n)= -0.9y(n 1)-0.81y(n 2)1.62x(n) +1.8r(n -1)+2x(n-2), n0 Find and plot r(n) and y(n) and hence find the energy of y(n) for the following cases: ( (d) a(n) r(n)r(n 25), where r(n) is the unit-ramp sequence. In this exercise we...

  • Please can you solve it using MATLAB. (1) Generate random signals [n] and hn, each of...

    Please can you solve it using MATLAB. (1) Generate random signals [n] and hn, each of length N, and measure the time it takes to compute the linear convolution of r[n using the linear convolution definition and using the FFT method . Plot a graph of the results for N 104 to 10 in steps of 10. (2) Consider the signal x[n]-cos(0.3n),。£11S 100. Generate a plot of: ·The magnitude and phase of the DTFT of x[n] for 0 2π The...

  • USING MATLAB 7. A Fibonacci sequence is composed of elements created by adding the two previous...

    USING MATLAB 7. A Fibonacci sequence is composed of elements created by adding the two previous elements. The simplest Fibonacci sequence starts with 1, 1 and proceeds as follows: 1,1,2,3,5,8,13, So, if f(1)-1 and f(2) -1, then f(3)-2)+f(1) We can represent this pattern as f(x) - f(x-1)+f(x-2). A Fibonacci sequence can be created with any two numbers. Prompt the user to enter the first two numbers in a Fibonacci sequence and the total number of elements requested in the sequence....

  • Can you help me with this question please? For the code, please do it on MATLAB. Thanks

    Can you help me with this question please? For the code, please do it on MATLAB. Thanks 7. Bonus [3+3+4pts] Before answering this question, read the Google page rank article on Pi- azza in the 'General Resources' section. The Google page rank algorithm has a lot to do with the eigenvector corresponding to the largest eigenvalue of a so-called stochastic matrix, which describes the links between websites.2 Stochastic matrices have non-negative entries and each column sums to1, and one can...

  • Solve using MATLAB (1) Consider the difference equation given follows as у(п) — — 0.9у(п -...

    Solve using MATLAB (1) Consider the difference equation given follows as у(п) — — 0.9у(п - 1) — 0.81у(n — 2) + 1.62г(п) + 1.82(п — 1) + 2ar (п — 2), п > 0. Find and plot x(n) and y(n) and hence find the energy of y(n) for the following cases (а) 2(п) — 8(п — 2) (b) 2(п) — и(п) 6(п — 3) _ (с) г(п) — и(п)u(-п + 23) _ (d) x(n)r(n) - r(n - 25), where...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT