Question: Problem 1: Here are some pseudocodes may be used in this problem: (i) Let us fix Monte Carlo iterations and a bin size . Moreover,

Problem 1:

Here are some pseudocodes may be used in this problem:

(i) Let us fix Monte Carlo iterations and a bin size . Moreover, since is positive, we can choose the bin centers . The following MATLAB code estimates the probability density function of based on measurements (realizations) of Y :

Step1:

Set N = 10000 and dy = 0.1; so the bincenters should be [dy/2:dy:8]; and the bin size is the length of the bincenters matrix.

Then generate a zero matrix h that by using the command zeros(bins,1);

Step2:

For each Monte Carlo iteration i from 1 to N

Set x1=randn(1); x2=randn(1);

Set y=x1^2+x2^2;

for k represent each bin from 1 to bins,

if (y>(bincenters(k)-dy/2))&(y<=(bincenters(k)+dy/2))

h(k)=h(k)+1;

Step3: Plot the figure.

pyest=h/(N*dy);

stem(bincenters,pyest); xlabel('y'); ylabel('p_Y(y)')

(ii) In order to perform the comparison you can use the MATLAB code.

hold on;

z = [0:0.01:9];

plot (z,1/2*exp(-z/2),'-')

The plot is shown in the figure below. Increasing the number of observations would improve the accuracy of the estimate.

Enter your code for this question here:

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