Lab Report: Course: EEE 4554 (Random Signal and Processes Lab) Experiment No. 1 Experiment Name: Introduction
Lab Report: Course: EEE 4554 (Random Signal and Processes Lab) Experiment No. 1 Experiment Name: Introduction
Submitted by:
Muhammad Sami Irfan
Std Id-132421
Sec-A1
Department-EEE
OUTPUT:
Random numbers using rand
1200
1000
800
600
400
200
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
4000
3500
3000
2500
2000
1500
1000
500
0
-5
-4
-3
-2
-1
1. Change the values inside the functions rand and randn i.e. change 10e4 to 10e2 and plot the
numbers using hist. Are the figures different from the figures shown above? Why?
Ans: OUTPUT:
Random numbers using rand
16
14
12
10
8
6
4
2
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
45
40
35
30
25
20
15
10
5
0
-4
-3
-2
-1
The figures differ from previous ones since the number of samples taken is smaller now. The greater
the number of samples the more the distribution resembles the ideal uniform and normal
distribution.
2. Now change the numbers to 10e5 and do the same thing. Are the figures different from the
previous figures? Why? Do the numbers of your figure 1 represent a more uniform distribution
now? If yes, then why?
Ans: OUTPUT:
Random numbers using rand
12000
10000
8000
6000
4000
2000
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
x 10
3.5
3
2.5
2
1.5
1
0.5
0
-6
-4
-2
The figures resemble the ideal case more closely now. The figures are different now since there are
greater number of samples and the rand and randn functions produce random outputs. The
numbers in figure 1 are more uniform now since there are a greater number of samples.
3. What happens if the number of bins of hist changes from 100 to 10? Generate figures.
Ans: Code:
close all
clear all
% Generating Random Numbers
A= rand (1,10e5);
B= randn (1,10e5);
% Statistical Visualization
figure (1)
hist (A,10)
title('Random numbers using rand' )
figure (2)
hist (B,10)
title('Random numbers using randn' )
OUTPUT:
4
12
x 10
10
0
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
3.5
x 10
2.5
1.5
0.5
0
-5
-4
-3
2)Coin toss:
CODE:
clear all;
close all;
clc;
n=1000;
for(j=1:n)
if(rand()<=1/2)
x(j)=1;
else
x(j)=0;
end
end
Heads=sum(x(x==1))
Tails=n-Heads
figure(1)
hist(x)
title('Histogram of x')
OUTPUT:
Heads =
486
Tails =
514
-2
-1
Histogram of x
600
500
400
300
200
100
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
Ans: OUTPUT:
250
200
150
100
50
6. If it is not uniform, then what can be inferred from this? How can you prove CLT from this?
Ans: The distribution resembles normal distribution. Hence, it satisfies the condition that, the sum of
a large number of independent random variables tends to be a Gaussian random variable.
7. Do the same for 30 random variables. What happens?
Ans: OUTPUT:
250
200
150
100
50
0
10
11
12
13
14
15
16
17
18
19
20