Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a MATLAB programsimilar to thefirst example program (and basically redo ref question 1) but this time use the randn function to generate a length

Write a MATLAB programsimilar to thefirst example program (and basically redo ref question 1) but this time use the randn function to generate a length M vector of Gaussian random numbers with mean -2 and variance 3 (use M = 50000). Include a subroutine that computes P(z>2) and compare to the theoretical value.Using an x-axis that goes from -6 to6 withDx= 0.1, plotthe actual pdfof this Gaussianrandom variable alongwith the estimated pdf using the hist function.

image text in transcribedimage text in transcribed
Using the 2 reference programs below... Write a MATLAB program similar to the first example program (and basically redo ref question 1) but this time use the randn function to generate a length M vector of Gaussian random numbers with mean -2 and variance 3 (use M = 50000). Include a subroutine that computes P(z>2) and compare to the theoretical value. Using an x-axis that goes from -6 to 6 with Ax= 0.1, plot the actual pdf of this Gaussian random variable along with the estimated pdf using the hist function. Ref Question 1: write a program that produces a vector of random numbers that are uniformly distributed between -3 and 7. Use M = 50000 and Ax= 0.1. Include a subroutine in your program that estimates the probability that the random variable is between 0 and 2. Compare this to the theoretical value. Plot the estimated pdf on an x-axis that goes from -5 to 9. In your plot, include the actual pdf of a random variable that is uniformly distributed between -3 and 7. Answer: clear % Given M and Delta x M = 50000; Dx = 0.1 6make vector of random numbers u.d. [-3.7] X = (7+3).*rand(1,M)-3; Mestimate probability that wv is between 0 and 2 N = 0; 9%initialize for i = 1:M if X(i)>=0 && X(0) 1.25. plots are shown in Figure 1. The output of the program estimates this as 0.0706. We can see from Figure 2, that fz(z) = 0.5A(z/2) (which is expected). From this we can find that the actual value of P(z>1.25) is M=100000; 0.0703. delta_x=0 . 05; X=4 *rand (1, M) +2; M=30000; $number of samples generated x_axis= [0 :delta_x: 8] ; x1=2*rand (1, M) -1; pdf_est=hist (X, x_axis) / (M*delta_x) ; x2=2*rand (1, M) -1; plot (x_axis, pdf_est) z=x1+x2; delta_x=0.1; 03 x_axis=[-3: delta_x:3] ; yes=0 ; for ii=1: length (z) if gt (z (ii) , 1.25) yes=yes+1; end 01 end 905 yes=yes/M fx=hist (z, x_axis) / (M*delta_x) ; plot (x_axis, fx) (a) Plot for M=5000 and Ar = 0.1. (c) Plot for M=100000 and Ar = 0.1. 0.5 03 0.45 0.25 0.4 02 0.35 0.3 0.15 0.15 0.25 01 0.2 0.15 0.1 0.05 (b) Plot for M=10000 and Ar = 0.1. (d) Plot for M=100000 and Ar = 0.05. Figure 1 Plots of estimated pdf of random variable Zoom is uniformly distributed between 2 and 6. Figure 2 Estimated pdf of z = x1+x2

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

Trigonometry (Subscription)

Authors: Mark Dugopolski

5th Edition

0135207487, 9780135207482

More Books

Students also viewed these Mathematics questions

Question

Describe three major themes in cognitive psychology.

Answered: 1 week ago