Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Let X be a random variable (r.v.) with pdf fx(x). Now consider another r.v. Z de

ID: 2292336 • Letter: L

Question

Let X be a random variable (r.v.) with pdf fx(x). Now consider another r.v. Z defined as Z g(x) with pdf fz(2). We define a vector xN of N random numbers drawn from a distribution with pdf fx(z). Then fz(z) can be approximated by the nor malized histogram of vector z [g(g Moreover, the mean value of r.v. Z is approximately equal to the mean value of the elements of vector z. For example, assume X is a Gaussian distributed r.v. with mean 0 and variance 1 and Z = cos (2?X). Then, we can calculate the pdf of Z, fz(z), and its mean by typing the following in MATLAB: x = randn (1, 10000) ; z cos (2*pi*x); histogram(z, 40, ); % normalized histogram (line not complete) mean (z) %mean value of z Now consider X and Y to be Gaussian distributed random variables with mean 0 and variance I. Use N = 100000 random numbers drawn from X and Y distributions to generate vectors x and y, respectively. Use 40 bins for the histograms. Create an M-file to: (a) Plot the histogram (normalized histogram) and calculate the mean of r.V. Za given by: Za X10

Explanation / Answer

.m file for problem(a)

clc;

close all;

clear all;
X=randn(1,100000);
Y=randn(1,100000);

Za=X+10;  
[f,x]=hist(Za,100); %Simulated PDF
bar(x,f/trapz(x,f));
hold on;
title('normalized histogram');
xlabel('x(n)');
ylabel('h');
ymean=mean(Za)
yvarience=var(Za)

.m file for problem(b)

clc;
close all;
clear all;
X=randn(1,100000);
Zb=X/2;
[f,x]=hist(Zb,100); %Simulated PDF
bar(x,f/trapz(x,f));
hold on;
title('normalized histogram');
xlabel('x(n)');
ylabel('h');
ymean=mean(Zb)
yvarience=var(Zb)

.m file for problem(b)

clc;
close all;
clear all;
X=randn(1,100000);
Y=randn(1,100000);
Zc=sqrt(X.^2+Y.^2);
[f,x]=hist(Zc,100); %Simulated PDF
bar(x,f/trapz(x,f));
hold on;
title('normalized histogram');
xlabel('x(n)');
ylabel('h');
ymean=mean(Zc)
yvarience=var(Zc)