-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathp2_transform_exponential.m
59 lines (55 loc) · 1.12 KB
/
p2_transform_exponential.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
clc;
clear;
close all;
T1 = 100;
T2 = 1000;
T3 = 10000;
lambda = 2;
% For 100 samples
for i = 1:length(T1)
gx = zeros(T1(i),1);
n = 1;
while n <= T1(i)
fx = exprnd(lambda,T1(i),1);
gx(n) = sum(fx)/T1(i);
n = n + 1;
end
figure(1);
subplot(1,1,i)
histogram(gx)
title("TRANSFORMED EXPONENTIAL RANDOM VARIABLE", T1(i))
xlabel("100 Samples");
ylabel("Frequency");
end
% 1000 Samples
for i = 1:length(T2)
gx = zeros(T2(i),1);
n = 1;
while n <= T2(i)
fx = exprnd(lambda,T2(i),1);
gx(n) = sum(fx)/T2(i);
n = n + 1;
end
figure(2);
subplot(1,1,i)
histogram(gx)
title("TRANSFORMED EXPONENTIAL RANDOM VARIABLE", T2(i))
xlabel("1000 Samples");
ylabel("Frequency");
end
% 10000 samples
for i = 1:length(T3)
gx = zeros(T3(i),1);
n = 1;
while n <= T3(i)
fx = exprnd(lambda,T3(i),1);
gx(n) = sum(fx)/T3(i);
n = n + 1;
end
figure(3);
subplot(1,1,i)
histogram(gx)
title("TRANSFORMED EXPONENTIAL RANDOM VARIABLE", T3(i))
xlabel("10000 Samples");
ylabel("Frequency");
end