clc;
A = List_A; %column vector containing time
duration for person A
B = List_B; %column vector containing time
duration for person B
C = List_C; %column vector containing time
duration for unknown person
Z_1 = zeros(length(A),1);
Z_2 = zeros(length(B),1);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%% Expectation %%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PART A
Exp_A = mean(A); %expectation of X
Exp_B = mean(B); %expectation of Y
PART B
AA = A.^2; %creating an array of X^2
BB = B.^2; %creating an array of Y^2
Exp_AA = mean(AA); %expectation of X^2
Exp_BB = mean(BB); %expectation of Y^2
Var_A = Exp_AA - Exp_A^2; %variance of X
Var_B = Exp_BB - Exp_B^2; %variance of Y
PART C
for i=1:length(A)
Z_1(i) = (A(i)-Exp_A)/(Var_A^0.5);
end
Exp_Z1 = mean(Z_1); %expectation of Z1
ZZ_1 = Z_1.^2; %Z1^2
Exp_ZZ1 = mean(ZZ_1); %expectation of Z1^2
Var_Z1 = Exp_ZZ1 - Exp_Z1^2; %variance of Z1
for k=1:length(B)
Z_2(k) = (B(i)-Exp_B)/(Var_B^0.5);
end
Exp_Z2 = mean(Z_2); %expectation of Z2
ZZ_2 = Z_2.^2; %Z2^2
Exp_ZZ2 = mean(ZZ_2); %expectation of Z2^2
Var_Z2 = Exp_ZZ2 - Exp_Z2^2; %variance of Z2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%% Display of Result %%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
disp(['Expectation of X is:',num2str(Exp_A)])
disp(['Expectation of Y is:',num2str(Exp_B)])
disp(['Expectation of X^2 is:',num2str(Exp_AA)])
disp(['Expectation of Y^2 is:',num2str(Exp_BB)])
disp(['Expectation of Z_1 is:',num2str(Exp_Z1)])
disp(['Variance of Z_1 is:',num2str(Var_Z1)])
disp(['Expectation of Z_2 is:',num2str(Exp_Z2)])
disp(['Variance of Z_2 is:',num2str(Var_Z2)])
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%% Result %%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expectation of X is:5452.1819
Expectation of Y is:5908.7768
Expectation of X^2 is:39571380.7675
Expectation of Y^2 is:46480843.4944
Expectation of Z_1 is:1.7836e-15
Variance of Z_1 is:1
Expectation of Z_2 is:1.7384
Variance of Z_2 is:-2.0872e-14