%Stat 351 % Kolmogorov Smirnov Test >>X=[0.1:0.1:1] X = 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 0.7000 0.8000 0.9000 1.0000 >>cdfplot(X) >>hold on %Testing N(0.5,1) HW1 Problem 1. >>Y=normrnd(0.5,1,1000,1); >>cdfplot(Y); >>normcdf(X,0.5,1) ans = 0.3446 0.3821 0.4207 0.4602 0.5000 0.5398 0.5793 0.6179 0.6554 0.6915 >>max(X-normcdf(X,0.5,1)) ans = 0.3085 >>1.36/sqrt(10) ans = 0.4301 %Testing Unif(0,1) >>max(X-unifcdf(X,0,1)) ans = 0 %Using built-in function >>[H,P]=kstest(X,[X',normcdf(X,0.5,1)']) P = 0.1466 >>[H,P] = kstest(X,[X',unifcdf(X,0,1)']) P = 0.9999 >>income =[9800 10200 9300 8700 15200 6900 8600 9600 12200 15500 11600 7200] >>Z = (income-mean(income))/std(income) Z = -0.2164 -0.0721 -0.3966 -0.6130 1.7308 -1.2621 -0.6491 -0.2885 0.6491 1.8390 0.4327 -1.1539 >>[H,P]=kstest(Z,[Z,normcdf(Z,0,1)]) P = 0.7002 >>[H,P]=lillietest(Z) P = NaN %NaN returned when P is not in the inverval [0.01, 0.20].