Matlab Seminar Report
Matlab Seminar Report
ISAE/AESS-1
f (x) = {
0
------ (1.a)
{}
= [
1
2()
2]
2 2
2()
(+)()
2()
----- (1.b)
= 2 f () (
+ 2
= 2 (
=
=
3 3
3()
2 +2+2
( 2 ++2 )
3
+ 2
)
2
+ 2
) = [3() 3 ] (
()( 2 ++2 )
2 +2+2
4
3()
2 2+2
12
2 +2+2
4
()2
12
----- (1.c)
Question 2.
Plot the PDF. Verify that the sum of the PDF is unity. Verify that the theoretical mean
and variance are in accordance with the numerical values obtained with Matlab.
Answer 2:
Here, we set a = 0 and b = 1.
Theoretical mean:
Theoretical variance:
2
()2
12
1+0
2
(10)2
12
= 0.5
(1.b)
= 0.0833
(1.c)
The numerical values of mean and variance are 0.5 and 0.0833 respectively. (see Appendix 1 for part
1 MATLAB code.) The following figure shows the PDF of a continuous uniform distribution on the
interval [0, 1]:
Question 3.
Draw N samples from the distribution. Plot these N realizations. Using these samples, compute
the empirical i) mean; ii) variance; iii) PDF. Verify that the sum of the empirical PDF is unity. In the
same figure, plot the theoretical PDF with that obtained with the samples.
Answer 3:
Here we set N = 100. The figure with N-samples and the empirical PDF is as follows:
The empirical mean of the 100-sample distribution is 0.518046, and its variance is 0.080124. The sum
of the empirical PDF is 1.047120. This is greater than 1, but this is likely due to the low number of
bins in the histogram. Increasing this number would remove the discrepancy.
Part 2 - The Gaussian distribution
(Let X denote a real Gaussian random variable with mean and standard deviation .)
Question 1.
Recall the expression of its PDF and derive analytically its mean and variance.
Answer 1.
The expression of a Gaussian PDF:
f (x) =
1
22
()2
22
------ (2.a)
2
+
= [( ) + ] 22
+
= ( ) 22
()2
22
+ +
2
= 2
2 ( ) (
()2
22
()2
22
+ 22
()2
22
()2
22
()2
+ 1
22
22
{} =
22
22
( 2 )
()2
22
V(X) = {( {})2 } = ( )2 f ()
+
V(X) =
( )
1
2 2
()2
22
we let =
2 2 2
V(X) =
2 2 2
2 2
, = 2 2
2 2
1
2 2
2 2
2 =
2 2
22
([
1
2
+ 1 2
) = lim (
) = 0,
22
+ 1 2
(0
) =
2
+
= 2 ( ) ----- (2.c)
Question 2.
Plot the PDF. Verify that the sum of the PDF is unity. Verify that the theoretical mean
and variance are in accordance with the numerical values obtained with Matlab.
Answer 2:
Here, we set mean = 0.0 and standard deviation = 1.0 . The numerical values of mean and
variance are 0.0 and 1.0 respectively. (see Appendix 2 for Part 2 MATLAB code). The PDF of Gaussian
distribution with = 0.0, = 1.0 is shown below:
Question 3.
Draw N samples from the distribution. Plot these N realizations. Using these samples, compute
the empirical i) mean; ii) variance; iii) PDF. Verify that the sum of the empirical PDF is unity. In the
same figure, plot the theoretical PDF with that obtained with the samples.
Answer 3:
Here, we set N = 500. The figure with N-samples and the empirical PDF is as follows:
The empirical mean of the 500-sample distribution is -0.074879, and its variance is 1.009664.
The sum of the PDF is 1.002004. (See Appendix 2 for MATLAB code.)
Question 2.
Construct two vectors: one containing the real part of the samples, and one containing the
imaginary part of the samples.
Answer 2:
See Appendix 3.2 for Part 3 MATLAB code.
Question 3.
For each vector, plot the realizations and the empirical PDF.
Answer 3:
The noise signal is plotted separately, in real and imaginary parts, in the following figure:
Histograms of the data and fitted PDFs for each component are shown below:
Figure 3.2: Noise Amplitude Histogram and PDF for each Signal Component
Question 4.
Infer the type of distribution that could follow both random variables XR and XI. Using Matlab
functions, fit the empirical PDFs to the type of distribution inferred. What are the values of the
parameters of the fitted PDFs?
Answer 4:
Both real part and imaginary part vector are fitted based on Matlab General model Gauss2. The
general equation is:
f(x) = 1
1 2
(
)
1
+ 2
2 2
)
2
For the real signal component, the parameters of the fitted PDF are:
a1 = 0.5268, b1 = 0.007966, c1 = 1.065, a2 = 0.01925, b2 = 0.287, c2 = 0.1534
For the imaginary part vector, the parameters of the fitted PDF are:
a1 = 0.003051, b1 = 0.3737, c1 = 0.01337, a2 = 0.5354, b2 = 0.007875, c2 = 1.049
Question 5.
Compute the correlation coefficient between XR and XI.
Answer 5:
The definition of correlation coefficient is:
=
x,y
where x,y is the covariance between random variables X and Y, and means the standard deviation
of X. The correlation coefficient between XR and XI, as found by the part 3 MATLAB code, is:
= -0.01577.
Question 6.
Plot the empirical joint PDF of XR and XI. From your observations propose a distribution that
could describe appropriately the vector [XR XI] T.
Answer 6:
Plot the empirical joint PDF of XR and XI.
The following figure is an empirical joint PDF of XR and XI:
Figure 3.3: Empirical Joint PDF of XR and XI, in Heatmap and 3D forms
Propose a distribution that could describe appropriately the vector [XR XI]T.
The covariance matrix of joint PDF is symmetric as well as semi-positive, and the plotting result
from figure 3.3 looks like typical Bivariate normal distribution model. Thus, we proposed Bivariate
normal distribution to fit the empirical joint PDF. The probability density function of multivariate
normal distribution in bivariate case is:
fXY (x, y) =
1
2 12
1
2(12 )
[(
) +(
) 2
( )( )
]} ----- (3.a)
The following figure shows a mesh-grid bivariate normal distribution, with the above parameters,
overlaying an experimental PDF surface, as in Fig. 3.3b.
The proposed distribution and the experimental distribution are very similar, indicating that our
assumption is correct that the empirical joint PDF could be described appropriately in Bivariate
normal distribution model.
APPENDIX
1. Part 1 MATLAB Code
%%
% File name: Uniform_Distribution.m
% Developer: Vikram Krishnaswamy AND Hao-Chih,LIN
% Date: 16/09/2016
%%
clear
clc
% Define parameters
a = 0;
b = 1;
range = b-a;
interval = 0.01;
% Plot PDF
x = a-range:interval:b+range;
y = unifpdf(x, a, b);
figure(1);
plot(x,y,'LineWidth',3);
hold on;
xlabel('x values');
ylabel('Probability Density');
title('The Uniform distribution');
% Plot the theoretical PDF with that obtained with the N-samples
histsamples = 20;
[hist_f, hist_x] = hist(n,histsamples);
histPDF = hist_f/trapz(hist_x,hist_f);
bar(hist_x, histPDF,'y');
fprintf('The sum of the empirical PDF is: %f\n', sum(histPDF) * ( hist_x(2)hist_x(1) ) );
% Date: 16/09/2016
%%
clear
clc
% Define parameters
mu = 0;
sigma = 1;
xaxis_min = -20;
xaxis_max = 20;
interval = 0.001;
% Plot PDF
x = xaxis_min:interval:xaxis_max;
y = normpdf(x, mu, sigma);
figure(1);
plot(x,y,'LineWidth',4);
hold on;
xlabel('x values');
ylabel('Probability Density');
title('The Gaussian distribution');
% Plot the theoretical PDF with that obtained with the N-samples
histsamples = 50;
[hist_f, hist_x] = hist(n,histsamples);
histPDF = hist_f/trapz(hist_x,hist_f);
bar(hist_x, histPDF,'y');
fprintf('The sum of the empirical PDF is: %f\n', sum(histPDF) * ( hist_x(2)hist_x(1) ) );
Size
Bytes
Class
noise
1x1
80176
struct
Attributes
%---------------------------------------------------------% Question.3: Plot the realizations and the empirical PDF for each vector.
% Question.4: Fit the empirical PDFs to the type of distribution inferred.
figure;
hold on;
histsamples = 25;
% Realizations of real part
realpoints = subplot(4,4,[1 5]);
plot(1:length(realpart), realpart, 'r.');
% Empirical PDF of real part
realprob = subplot(4,4,[9 13]);
ylabel(realpoints, 'amplitude');
ylabel(imagpoints, 'amplitude');
ylabel(realprob, 'probability density');
ylabel(imagprob, 'probability density');
ylabel(bivarpdf_surf, 'Real Distribution');
ylabel(bivarpdf_sc, 'Real Distribution');
ylabel(bivargauss, 'Real Distribution');