clear all
close all
clc
linearcng(); % Function which generate Random Variaable
randNum=Rand_Data; % Rand_Data is a vector which have random numbers generated by Linear Congurational Method
sort_randNum=sort(randNum);
degFree=length(randNum);
temp_Matrix2(1)=0;
for loopItr7=1:degFree
temp_Matrix1(loopItr7)=loopItr7/degFree;
end
temp_Matrix3=temp_Matrix1-sort_randNum;
for loopItr7=1:degFree-1
temp_Matrix2(loopItr7+1)=loopItr7/degFree;
end
temp_Matrix4=sort_randNum-temp_Matrix2;
temp_Matrix5=[max(temp_Matrix3) max(temp_Matrix4)];
% D = Deviation from imperical CDF
D=max(temp_Matrix5);
levelSig=input('enter the level of significance 0.10 or 0.05 or 0.001 : ');
%%%%%%%%%%%%% Reading ctitical value of Deviation from file KS Test.txt %%%%%%%%%%%%%
fid=fopen('KS Test.txt','r')
f=fscanf(fid, '%f',inf);
loopItr8=1;
temp_Variable1=length(f);
if (degFree>20&°Free<25)
degFree=20;
elseif (degFree>25&°Free<30)
degFree=25;
elseif (degFree>30&°Free<35)
degFree=30;
end
if((degFree<21 && degFree>0) || degFree==25 || degFree==30 || degFree==35 )
while loopItr8<temp_Variable1
if(f(loopItr8)==degFree)
switch levelSig
case 0.10
Deviation=f(loopItr8+1);
loopItr8=loopItr8+temp_Variable1;
case 0.05
Deviation=f(loopItr8+2);
loopItr8=loopItr8+temp_Variable1;
case 0.001
Deviation=f(loopItr8+3);
loopItr8=loopItr8+temp_Variable1;
end
else
loopItr8=loopItr8+4;
end
end
else
switch levelSig
case 0.10
Deviation=1.22/(sqrt(degFree));
case 0.05
Deviation=1.36/(sqrt(degFree));
case 0.001
Deviation=1.63/(sqrt(degFree));
end
end
fprintf('\n \n THe Deviation D = %1.3f \n\n and the ctitical value of deviation for level of significance %1.3f is D(%1.3f) = %1.3f \n\n',D,levelSig,levelSig,Deviation)
if(D<Deviation)
disp('We have failed to reject the null HYpothesis ')
else
disp('So we reject the null Hypothesis ')
end
fclose(fid);