You are on page 1of 28

ASSIGNMENT NO:-2

#Q1

> library(randtests)

> z=c(0.324,0.485,0.724,0.624,0.135,0.821,0.514,0.635,0.292,0.443,0.356,0.629);z

[1] 0.324 0.485 0.724 0.624 0.135 0.821 0.514 0.635 0.292 0.443 0.356 0.629

> y=runs.test(z);y

Runs Test

data: z

statistic = -0.60553, runs = 6, n1 = 6, n2 = 6, n = 12, p-value =

0.5448

alternative hypothesis: nonrandomness

> Tcal=y$statistic;Tcal

statistic

-0.6055301

> pv=y$p.value;pv

[1] 0.5448269

> los=0.05

> cat("H0:Generated numbers are random against H1:Generated numbers are not random\n");

H0:Generated numbers are random against H1:Generated numbers are not random

> cat("computed test statistic:",Tcal,"\n");

computed test statistic: -0.6055301

> cat("pvalue:",pv,"\n");

pvalue: 0.5448269

> los1=100*los;los1

[1] 5

> if(pv<los){cat("since,pv<los Reject H0 at",los1,"% level of significance\n");}else{cat("since pv>los


Accept H0 at",los1,"% level of significance\n");}

since pv>los Accept H0 at 5 % level of significance


**********************************************************************************

> ##Q2.

>
z=c(0.05,0.41,0.68,0.89,0.94,0.74,0.91,0.55,0.62,0.36,0.27,0.19,0.72,0.75,0.08,0.54,0.02,0.01,0.36,0.
16,0.28,0.18,0.01,0.95,0.69,0.18,0.47,0.23,0.32,0.82,0.53,0.31,0.42,0.73,0.04,0.83,0.45,0.13,0.57,0.6
3,0.29);z

[1] 0.05 0.41 0.68 0.89 0.94 0.74 0.91 0.55 0.62 0.36 0.27 0.19 0.72 0.75 0.08

[16] 0.54 0.02 0.01 0.36 0.16 0.28 0.18 0.01 0.95 0.69 0.18 0.47 0.23 0.32 0.82

[31] 0.53 0.31 0.42 0.73 0.04 0.83 0.45 0.13 0.57 0.63 0.29

> y=runs.test(z);y

Runs Test

data: z

statistic = -0.64072, runs = 19, n1 = 20, n2 = 20, n = 40, p-value =

0.5217

alternative hypothesis: nonrandomness

> Tcal=y$statistic;Tcal

statistic

-0.6407233

> pv=y$p.value;pv

[1] 0.5217025

> los=0.05

> cat("H0:Generated numbers are random against H1:Generated numbers are not random\n");

H0:Generated numbers are random against H1:Generated numbers are not random

> cat("computed test statistic:",Tcal,"\n");

computed test statistic: -0.6407233

> cat("pvalue:",pv,"\n");

pvalue: 0.5217025

> los1=100*los;los1

[1] 5
> if(pv<los){cat("since,pv<los Reject H0 at",los1,"% level of significance \n");}else{cat("since pv>los
Accept H0 at",los1,"% level of significance\n");}

since pv>los Accept H0 at 5 % level of significance

**********************************************************************************

> #Q3.

> ofreq=c(680,289,31);ofreq

[1] 680 289 31

> N=sum(ofreq);N

[1] 1000

> k=length(ofreq);k

[1] 3

> p=c(0.72,0.27,0.01);p

[1] 0.72 0.27 0.01

> efreq=rep(N*p);efreq

[1] 720 270 10

> los=0.05;

> cat("Using poker's test","\n")

Using poker's test

> cat("To Test:H0:Random numbers are independent against H1:Random numbers are not
independent \n");

To Test:H0:Random numbers are independent against H1:Random numbers are not independent

> Tcal=sum(((ofreq-efreq)^2)/efreq);Tcal

[1] 47.65926

> pv=pchisq(Tcal,df=(k-1),lower.tail=F);

> cat("computed test statistic:",Tcal,"\n");

computed test statistic: 47.65926

> cat("pvalue:",pv,"\n");

pvalue: 4.476343e-11

> los1=100*los;> if(pv<los){cat("Since,pv<los Reject H0 at",los1,"% level of

significance\n");}else{cat("since pv>los at",los1,"% level of significance\n");}

Since,pv<los Reject H0 at 5 % level of significance


**********************************************************************************

> ##Q4.

> library(randtests)

> lcg<-function(a,c,m,run.length,seed)

+{

+ x<-rep(0,run.length)

+ x[1]<-seed

+ for(i in 1:(run.length-1))

+{

+ x[i+1]<-c(a*x[i]+c)%%m

+}

+ u<-x/m # scale all of x's to uniformly distributed random number between(0,1)

+ return(list(x=x,u=u))

+}

>

> # a=13,c=3,m=26 and x0=1234

> los=0.05

>

> z1=lcg(13,3,26,30,1);z1

$x

[1] 1 16 3 16 3 16 3 16 3 16 3 16 3 16 3 16 3 16 3 16 3 16 3 16 3

[26] 16 3 16 3 16

$u

[1] 0.03846154 0.61538462 0.11538462 0.61538462 0.11538462 0.61538462

[7] 0.11538462 0.61538462 0.11538462 0.61538462 0.11538462 0.61538462

[13] 0.11538462 0.61538462 0.11538462 0.61538462 0.11538462 0.61538462

[19] 0.11538462 0.61538462 0.11538462 0.61538462 0.11538462 0.61538462

[25] 0.11538462 0.61538462 0.11538462 0.61538462 0.11538462 0.61538462

> d=runs.test(z1$u)
> Tcal=d$statistic;Tcal

statistic

5.202563

> pv=d$p.value;pv

[1] 1.965582e-07

> los=0.05

> cat("H0:Generated numbers are random at H1:Generated numbers are not random\n");

H0:Generated numbers are random at H1:Generated numbers are not random

> cat("computed test statistics:",Tcal,"\n");

computed test statistics: 5.202563

> cat("pvalue:",pv,"\n");

pvalue: 1.965582e-07

> los1=100*los;

> if(pv<los){cat("since,pv<los reject H0 at",los1,"% level of significance\n");}else{cat("since pv>los


at",los1,"% level of significance\n");}

since,pv<los reject H0 at 5 % level of significance

>

>

> z2=lcg(13,3,26,30,2);z2

$x

[1] 2 3 16 3 16 3 16 3 16 3 16 3 16 3 16 3 16 3 16 3 16 3 16 3 16

[26] 3 16 3 16 3

$u

[1] 0.07692308 0.11538462 0.61538462 0.11538462 0.61538462 0.11538462

[7] 0.61538462 0.11538462 0.61538462 0.11538462 0.61538462 0.11538462

[13] 0.61538462 0.11538462 0.61538462 0.11538462 0.61538462 0.11538462

[19] 0.61538462 0.11538462 0.61538462 0.11538462 0.61538462 0.11538462

[25] 0.61538462 0.11538462 0.61538462 0.11538462 0.61538462 0.11538462

> d=runs.test(z2$u)
> Tcal=d$statistic;Tcal

statistic

-2.54951

> pv=d$p.value;pv

[1] 0.01078745

> los=0.05

> cat("H0:Generated numbers are random against H1:Generated numbers are not random\n");

H0:Generated numbers are random against H1:Generated numbers are not random

> cat("computed test statistics:",Tcal,"\n");

computed test statistics: -2.54951

> cat("pvalue:",pv,"\n");

pvalue: 0.01078745

> los1=100*los;

> if(pv<los){cat("since,pv<los reject H0 at",los1,"% level of significance\n");}else{cat("since pv>los


at",los1,"% level of significance\n");}

since,pv<los reject H0 at 5 % level of significance

>

> z3=lcg(13,3,26,30,3);z3

$x

[1] 3 16 3 16 3 16 3 16 3 16 3 16 3 16 3 16 3 16 3 16 3 16 3 16 3

[26] 16 3 16 3 16

$u

[1] 0.1153846 0.6153846 0.1153846 0.6153846 0.1153846 0.6153846 0.1153846

[8] 0.6153846 0.1153846 0.6153846 0.1153846 0.6153846 0.1153846 0.6153846

[15] 0.1153846 0.6153846 0.1153846 0.6153846 0.1153846 0.6153846 0.1153846

[22] 0.6153846 0.1153846 0.6153846 0.1153846 0.6153846 0.1153846 0.6153846

[29] 0.1153846 0.6153846

> d=runs.test(z3$u)

> Tcal=d$statistic;Tcal
statistic

5.202563

> pv=d$p.value;pv

[1] 1.965582e-07

> los=0.05

> cat("H0:Generated numbers are random against H1:Generated numbers are not random\n");

H0:Generated numbers are random against H1:Generated numbers are not random

> cat("computed test statistics:",Tcal,"\n");

computed test statistics: 5.202563

> cat("pvalue:",pv,"\n");

pvalue: 1.965582e-07

> los1=100*los;

> if(pv<los){cat("since,pv<los reject H0 at",los1,"% level of significance\n");}else{cat("since pv>los


at",los1,"% level of significance\n");}

since,pv<los reject H0 at 5 % level of significance

>

> z4=lcg(13,3,26,30,4);z4

$x

[1] 4 3 16 3 16 3 16 3 16 3 16 3 16 3 16 3 16 3 16 3 16 3 16 3 16

[26] 3 16 3 16 3

$u

[1] 0.1538462 0.1153846 0.6153846 0.1153846 0.6153846 0.1153846 0.6153846

[8] 0.1153846 0.6153846 0.1153846 0.6153846 0.1153846 0.6153846 0.1153846

[15] 0.6153846 0.1153846 0.6153846 0.1153846 0.6153846 0.1153846 0.6153846

[22] 0.1153846 0.6153846 0.1153846 0.6153846 0.1153846 0.6153846 0.1153846

[29] 0.6153846 0.1153846

> d=runs.test(z4$u)

> Tcal=d$statistic;Tcal

statistic
5.202563

> pv=d$p.value;pv

[1] 1.965582e-07

> los=0.05

> cat("H0:Generated numbers are random against H1:Generated numbers are not random\n");

H0:Generated numbers are random against H1:Generated numbers are not random

> cat("computed test statistics:",Tcal,"\n");

computed test statistics: 5.202563

> cat("pvalue:",pv,"\n");

pvalue: 1.965582e-07

> los1=100*los;

> if(pv<los){cat("since,pv<los reject H0 at",los1,"% level of significance\n");}else{cat("since pv>los


at",los1,"% level of significance\n");}

since,pv<los reject H0 at 5 % level of significance

> *******************************************************************************

>

> ##Q5.

> ofreq=c(560,394,32,13,1);ofreq

[1] 560 394 32 13 1

> N=sum(ofreq);N

[1] 1000

> k=length(ofreq);k

[1] 5

> p=c(0.504,0.432,0.027,0.036,0.001);p

[1] 0.504 0.432 0.027 0.036 0.001

> efreq=rep(N*p);efreq

[1] 504 432 27 36 1

> los=0.05;

> cat("Using poker's test","\n")

Using poker's test


> cat("To Test:H0:Random numbers are independent against H1:Random numbers are not
independent \n");

To Test:H0:Random numbers are independent against H1:Random numbers are not independent

> Tcal=sum(((ofreq-efreq)^2)/efreq);Tcal

[1] 25.18519

> pv=pchisq(Tcal,df=(k-1),lower.tail=F);pv

[1] 4.61752e-05

> cat("computed test statistic:",Tcal,"\n");

computed test statistic: 25.18519

> cat("pvalue:",pv,"\n");

pvalue: 4.61752e-05

> los1=100*los;los1

[1] 5

> if(pv<los){cat("Since,pv<los Reject H0 at",los1,"% level of significance\n");}else{cat("since pv>los


at",los1,"% level of significance\n");}

Since,pv<los Reject H0 at 5 % level of significance

***********************************************************************

> ##Q6.

>

> lcg<-function(a,c,m,run.length,seed)

+{

+ x<-rep(0,run.length)

+ x[1]<-seed

+ for(i in 1:(run.length-1))

+{

+ x[i+1]<-(a*x[i]+c)%%m

+}

+ U<-x/m

+ #produce uniformly distributed

+ #random numbers between[0,1]

+ return (list(x=x,U=U))
+}

>

> z<-lcg(125,1,2^12,1000,1);z #seed is 1

$x

[1] 1 126 3463 2796 1341 3786 2211 1944 1337 3286 1151 516 3061 1698

[15] 3355 1584 1393 2094 3703 28 3501 3450 1171 3016 169 646 2927 1332

[29] 2661 850 3851 2144 1761 3038 2919 332 541 2090 3203 3064 2073 1078

[43] 3679 1124 1237 3074 3323 1680 1105 2958 1111 3708 653 3802 115 2088

[57] 2953 486 3407 3988 2885 178 1771 192 3521 1854 2375 1964 3837 394

[71] 99 88 2809 2966 2111 1732 3509 354 3291 1776 817 3822 2615 3292

[85] 1901 58 3155 1160 1641 326 3887 2548 3109 3602 3787 2336 1185 670

[99] 1831 3596 3037 2794 1091 1208 3545 758 543 2340 1685 1730 3259 1872

[113] 529 590 23 2876 3149 410 2099 232 329 166 271 1108 3333 2930

[127] 1707 384 2945 3582 1287 1132 2237 1098 2083 2328 185 2646 3071 2948

[141] 3957 3106 3227 1968 241 1454 1527 2460 301 762 1043 3400 3113 6

[155] 751 3764 3557 2258 3723 2528 609 2398 743 2764 1437 3498 3075 3448

[169] 921 438 1503 3556 2133 386 3195 2064 4049 2318 3031 2044 1549 1114

[183] 4083 2472 1801 3942 1231 2324 3781 1586 1643 576 2369 1214 199 300

[197] 637 1802 4067 472 1657 2326 4031 68 309 1762 3163 2160 3761 3182

[211] 439 1628 2797 1466 3027 1544 489 3782 1711 884 4005 914 3659 2720

[225] 33 30 3751 1932 3933 106 963 1592 2393 118 2463 676 2581 3138

[239] 3131 2256 3473 4046 1943 1212 4045 1818 1971 616 3273 3622 2191 3540

[253] 133 242 1579 768 1793 2942 3207 3564 3133 2506 1955 2712 3129 2006

[267] 895 1284 757 418 3099 2352 3185 814 3447 796 1197 2170 915 3784

[281] 1961 3462 2671 2100 357 3666 3595 2912 3553 1758 2663 1100 2333 810

[295] 2947 3832 3865 3894 3423 1892 3029 1794 3067 2448 2897 1678 855 380

[309] 2445 2522 3955 2856 649 3302 3151 660 581 2994 1515 960 1217 574

[323] 2119 2732 1533 3210 3939 856 505 1686 1855 2500 1205 3170 3035 2544

[337] 2609 2542 2359 4060 3693 2874 2899 1928 3433 3142 3631 3316 805 2322

[351] 3531 3104 2977 3486 1575 268 733 1514 835 1976 1241 3574 287 3108

[365] 3477 450 3003 2640 2321 3406 3863 3644 845 3226 1843 1000 2121 2982
[379] 15 1876 1029 1650 1451 1152 641 2302 1031 1900 4029 3914 1827 3096

[393] 1977 1366 2815 3716 1653 1826 2971 2736 2033 174 1271 3228 2093 3578

[407] 787 72 809 2822 495 436 1253 978 3467 3296 2401 1118 487 3532

[421] 3229 2218 2819 120 2713 3254 1247 228 3925 3202 2939 2832 1745 1038

[435] 2775 2812 3341 3930 3827 3240 3593 2662 975 3092 1477 306 1387 1344

[449] 65 4030 4039 1068 2429 522 3811 1240 3449 1046 3775 836 2101 482

[463] 2907 2928 1457 1902 183 2396 493 186 2771 2312 2281 2502 1455 1652

[477] 1701 3730 3403 3488 1825 2846 3495 2700 1629 2922 707 2360 89 2934

[491] 2207 1444 277 1858 2875 3024 1169 2766 1687 1980 1741 538 1715 1384

[505] 969 2342 1935 212 1925 3058 1323 1536 3585 1662 2951 236 829 1226

[519] 1699 3480 825 726 639 2052 2549 3234 2843 3120 881 3630 3191 1564

[533] 2989 890 659 456 3753 2182 2415 2868 2149 2386 3339 3680 1249 478

[547] 2407 1868 29 3626 2691 504 1561 2614 3167 2660 725 514 2811 3216

[561] 593 398 599 1148 141 1242 3699 3624 2441 2022 2895 1428 2373 1714

[575] 1259 1728 3009 3390 1863 3500 3325 1930 3683 1624 2297 406 1599 3268

[589] 2997 1890 2779 3312 305 1262 2103 732 1389 1594 2643 2696 1129 1862

[603] 3375 4084 2597 1042 3275 3872 673 2206 1319 1036 2525 234 579 2744

[617] 3033 2294 31 3876 1173 3266 2747 3408 17 2126 3607 316 2637 1946

[631] 1587 1768 3913 1702 3855 2644 2821 370 1195 1920 2433 1022 775 2668

[645] 1725 2634 1571 3864 3769 86 2559 388 3445 546 2715 3504 3825 2990

[659] 1015 3996 3885 2298 531 840 2601 1542 239 1204 3045 3794 3211 4064

[673] 97 3934 231 204 925 938 2563 888 409 1974 991 996 1621 1922

[687] 2683 3600 3537 3854 2519 3580 1037 2650 3571 4008 1289 1382 719 3860

[701] 3269 3122 1131 2112 1857 2750 3783 1836 125 3338 3555 2008 1145 3862

[715] 3519 1604 3893 3298 2651 3696 3249 622 4023 3164 2285 3002 2515 3080

[729] 4073 1222 1199 2420 3493 2450 3147 160 3617 1566 3239 3468 3421 1642

[743] 451 3128 1881 1654 1951 2212 2069 578 2619 3792 2961 1486 1431 2748

[757] 3533 3354 1459 2152 2761 1062 1679 980 3717 1778 1067 2304 1281 382

[771] 2695 1004 2621 4042 1443 152 2617 3542 383 2820 245 1954 2587 3888

[785] 2673 2350 2935 2332 685 3706 403 1224 1449 902 2159 3636 3941 1106

[799] 3083 352 3041 3294 2151 2636 1821 2346 2435 1272 3353 1334 2911 3428
[813] 2517 3330 2555 3984 2385 3214 343 1916 1933 4058 3443 296 137 742

[827] 2639 2196 69 434 1003 2496 705 2110 1607 172 1021 650 3427 2392

[841] 4089 3222 1343 4036 693 610 2523 4080 2097 4078 1847 1500 3181 314

[855] 2387 3464 2921 582 3119 756 293 3858 3019 544 2465 926 1063 1804

[869] 221 3050 323 3512 729 1014 3871 548 2965 1986 2491 80 1809 846

[883] 3351 1084 333 666 1331 2536 1609 422 3599 3412 517 3186 939 2688

[897] 129 3838 519 3436 3517 1354 1315 536 1465 2902 2303 1156 1141 3362

[911] 2459 176 1521 1710 759 668 1581 1018 275 1608 297 262 4079 1972

[925] 741 2514 2955 736 1889 2654 4071 972 2717 3754 2307 1656 2201 694

[939] 735 1764 3413 642 2427 272 1233 2574 2263 252 2829 1370 3315 680

[953] 3081 102 463 532 965 1842 875 2880 3649 1470 3527 2604 1917 2058

[967] 3299 2776 2937 2582 3263 2372 1589 2018 2395 368 945 3438 3767 3932

[981] 4077 1722 2259 3848 1769 4038 943 3188 1189 1170 2891 928 1313 286

[995] 2983 140 1117 362 195 3896

$U

[1] 0.0002441406 0.0307617188 0.8454589844 0.6826171875 0.3273925781

[6] 0.9243164062 0.5397949219 0.4746093750 0.3264160156 0.8022460938

[11] 0.2810058594 0.1259765625 0.7473144531 0.4145507812 0.8190917969

[16] 0.3867187500 0.3400878906 0.5112304688 0.9040527344 0.0068359375

[21] 0.8547363281 0.8422851562 0.2858886719 0.7363281250 0.0412597656

[26] 0.1577148438 0.7145996094 0.3251953125 0.6496582031 0.2075195312

[31] 0.9401855469 0.5234375000 0.4299316406 0.7416992188 0.7126464844

[36] 0.0810546875 0.1320800781 0.5102539062 0.7819824219 0.7480468750

[41] 0.5061035156 0.2631835938 0.8981933594 0.2744140625 0.3020019531

[46] 0.7504882812 0.8112792969 0.4101562500 0.2697753906 0.7221679688

[51] 0.2712402344 0.9052734375 0.1594238281 0.9282226562 0.0280761719

[56] 0.5097656250 0.7209472656 0.1186523438 0.8317871094 0.9736328125

[61] 0.7043457031 0.0434570312 0.4323730469 0.0468750000 0.8596191406

[66] 0.4526367188 0.5798339844 0.4794921875 0.9367675781 0.0961914062

[71] 0.0241699219 0.0214843750 0.6857910156 0.7241210938 0.5153808594


[76] 0.4228515625 0.8566894531 0.0864257812 0.8034667969 0.4335937500

[81] 0.1994628906 0.9331054688 0.6384277344 0.8037109375 0.4641113281

[86] 0.0141601562 0.7702636719 0.2832031250 0.4006347656 0.0795898438

[91] 0.9489746094 0.6220703125 0.7590332031 0.8793945312 0.9245605469

[96] 0.5703125000 0.2893066406 0.1635742188 0.4470214844 0.8779296875

[101] 0.7414550781 0.6821289062 0.2663574219 0.2949218750 0.8654785156

[106] 0.1850585938 0.1325683594 0.5712890625 0.4113769531 0.4223632812

[111] 0.7956542969 0.4570312500 0.1291503906 0.1440429688 0.0056152344

[116] 0.7021484375 0.7687988281 0.1000976562 0.5124511719 0.0566406250

[121] 0.0803222656 0.0405273438 0.0661621094 0.2705078125 0.8137207031

[126] 0.7153320312 0.4167480469 0.0937500000 0.7189941406 0.8745117188

[131] 0.3142089844 0.2763671875 0.5461425781 0.2680664062 0.5085449219

[136] 0.5683593750 0.0451660156 0.6459960938 0.7497558594 0.7197265625

[141] 0.9660644531 0.7583007812 0.7878417969 0.4804687500 0.0588378906

[146] 0.3549804688 0.3728027344 0.6005859375 0.0734863281 0.1860351562

[151] 0.2546386719 0.8300781250 0.7600097656 0.0014648438 0.1833496094

[156] 0.9189453125 0.8684082031 0.5512695312 0.9089355469 0.6171875000

[161] 0.1486816406 0.5854492188 0.1813964844 0.6748046875 0.3508300781

[166] 0.8540039062 0.7507324219 0.8417968750 0.2248535156 0.1069335938

[171] 0.3669433594 0.8681640625 0.5207519531 0.0942382812 0.7800292969

[176] 0.5039062500 0.9885253906 0.5659179688 0.7399902344 0.4990234375

[181] 0.3781738281 0.2719726562 0.9968261719 0.6035156250 0.4396972656

[186] 0.9624023438 0.3005371094 0.5673828125 0.9230957031 0.3872070312

[191] 0.4011230469 0.1406250000 0.5783691406 0.2963867188 0.0485839844

[196] 0.0732421875 0.1555175781 0.4399414062 0.9929199219 0.1152343750

[201] 0.4045410156 0.5678710938 0.9841308594 0.0166015625 0.0754394531

[206] 0.4301757812 0.7722167969 0.5273437500 0.9182128906 0.7768554688

[211] 0.1071777344 0.3974609375 0.6828613281 0.3579101562 0.7390136719

[216] 0.3769531250 0.1193847656 0.9233398438 0.4177246094 0.2158203125

[221] 0.9777832031 0.2231445312 0.8933105469 0.6640625000 0.0080566406

[226] 0.0073242188 0.9157714844 0.4716796875 0.9602050781 0.0258789062


[231] 0.2351074219 0.3886718750 0.5842285156 0.0288085938 0.6013183594

[236] 0.1650390625 0.6301269531 0.7661132812 0.7644042969 0.5507812500

[241] 0.8479003906 0.9877929688 0.4743652344 0.2958984375 0.9875488281

[246] 0.4438476562 0.4812011719 0.1503906250 0.7990722656 0.8842773438

[251] 0.5349121094 0.8642578125 0.0324707031 0.0590820312 0.3854980469

[256] 0.1875000000 0.4377441406 0.7182617188 0.7829589844 0.8701171875

[261] 0.7648925781 0.6118164062 0.4772949219 0.6621093750 0.7639160156

[266] 0.4897460938 0.2185058594 0.3134765625 0.1848144531 0.1020507812

[271] 0.7565917969 0.5742187500 0.7775878906 0.1987304688 0.8415527344

[276] 0.1943359375 0.2922363281 0.5297851562 0.2233886719 0.9238281250

[281] 0.4787597656 0.8452148438 0.6520996094 0.5126953125 0.0871582031

[286] 0.8950195312 0.8776855469 0.7109375000 0.8674316406 0.4291992188

[291] 0.6501464844 0.2685546875 0.5695800781 0.1977539062 0.7194824219

[296] 0.9355468750 0.9436035156 0.9506835938 0.8356933594 0.4619140625

[301] 0.7395019531 0.4379882812 0.7487792969 0.5976562500 0.7072753906

[306] 0.4096679688 0.2087402344 0.0927734375 0.5969238281 0.6157226562

[311] 0.9655761719 0.6972656250 0.1584472656 0.8061523438 0.7692871094

[316] 0.1611328125 0.1418457031 0.7309570312 0.3698730469 0.2343750000

[321] 0.2971191406 0.1401367188 0.5173339844 0.6669921875 0.3742675781

[326] 0.7836914062 0.9616699219 0.2089843750 0.1232910156 0.4116210938

[331] 0.4528808594 0.6103515625 0.2941894531 0.7739257812 0.7409667969

[336] 0.6210937500 0.6369628906 0.6206054688 0.5759277344 0.9912109375

[341] 0.9016113281 0.7016601562 0.7077636719 0.4707031250 0.8381347656

[346] 0.7670898438 0.8864746094 0.8095703125 0.1965332031 0.5668945312

[351] 0.8620605469 0.7578125000 0.7268066406 0.8510742188 0.3845214844

[356] 0.0654296875 0.1789550781 0.3696289062 0.2038574219 0.4824218750

[361] 0.3029785156 0.8725585938 0.0700683594 0.7587890625 0.8488769531

[366] 0.1098632812 0.7331542969 0.6445312500 0.5666503906 0.8315429688

[371] 0.9431152344 0.8896484375 0.2062988281 0.7875976562 0.4499511719

[376] 0.2441406250 0.5178222656 0.7280273438 0.0036621094 0.4580078125

[381] 0.2512207031 0.4028320312 0.3542480469 0.2812500000 0.1564941406


[386] 0.5620117188 0.2517089844 0.4638671875 0.9836425781 0.9555664062

[391] 0.4460449219 0.7558593750 0.4826660156 0.3334960938 0.6872558594

[396] 0.9072265625 0.4035644531 0.4458007812 0.7253417969 0.6679687500

[401] 0.4963378906 0.0424804688 0.3103027344 0.7880859375 0.5109863281

[406] 0.8735351562 0.1921386719 0.0175781250 0.1975097656 0.6889648438

[411] 0.1208496094 0.1064453125 0.3059082031 0.2387695312 0.8464355469

[416] 0.8046875000 0.5861816406 0.2729492188 0.1188964844 0.8623046875

[421] 0.7883300781 0.5415039062 0.6882324219 0.0292968750 0.6623535156

[426] 0.7944335938 0.3044433594 0.0556640625 0.9582519531 0.7817382812

[431] 0.7175292969 0.6914062500 0.4260253906 0.2534179688 0.6774902344

[436] 0.6865234375 0.8156738281 0.9594726562 0.9343261719 0.7910156250

[441] 0.8771972656 0.6499023438 0.2380371094 0.7548828125 0.3605957031

[446] 0.0747070312 0.3386230469 0.3281250000 0.0158691406 0.9838867188

[451] 0.9860839844 0.2607421875 0.5930175781 0.1274414062 0.9304199219

[456] 0.3027343750 0.8420410156 0.2553710938 0.9216308594 0.2041015625

[461] 0.5129394531 0.1176757812 0.7097167969 0.7148437500 0.3557128906

[466] 0.4643554688 0.0446777344 0.5849609375 0.1203613281 0.0454101562

[471] 0.6765136719 0.5644531250 0.5568847656 0.6108398438 0.3552246094

[476] 0.4033203125 0.4152832031 0.9106445312 0.8308105469 0.8515625000

[481] 0.4455566406 0.6948242188 0.8532714844 0.6591796875 0.3977050781

[486] 0.7133789062 0.1726074219 0.5761718750 0.0217285156 0.7163085938

[491] 0.5388183594 0.3525390625 0.0676269531 0.4536132812 0.7019042969

[496] 0.7382812500 0.2854003906 0.6752929688 0.4118652344 0.4833984375

[501] 0.4250488281 0.1313476562 0.4187011719 0.3378906250 0.2365722656

[506] 0.5717773438 0.4724121094 0.0517578125 0.4699707031 0.7465820312

[511] 0.3229980469 0.3750000000 0.8752441406 0.4057617188 0.7204589844

[516] 0.0576171875 0.2023925781 0.2993164062 0.4147949219 0.8496093750

[521] 0.2014160156 0.1772460938 0.1560058594 0.5009765625 0.6223144531

[526] 0.7895507812 0.6940917969 0.7617187500 0.2150878906 0.8862304688

[531] 0.7790527344 0.3818359375 0.7297363281 0.2172851562 0.1608886719

[536] 0.1113281250 0.9162597656 0.5327148438 0.5895996094 0.7001953125


[541] 0.5246582031 0.5825195312 0.8151855469 0.8984375000 0.3049316406

[546] 0.1166992188 0.5876464844 0.4560546875 0.0070800781 0.8852539062

[551] 0.6569824219 0.1230468750 0.3811035156 0.6381835938 0.7731933594

[556] 0.6494140625 0.1770019531 0.1254882812 0.6862792969 0.7851562500

[561] 0.1447753906 0.0971679688 0.1462402344 0.2802734375 0.0344238281

[566] 0.3032226562 0.9030761719 0.8847656250 0.5959472656 0.4936523438

[571] 0.7067871094 0.3486328125 0.5793457031 0.4184570312 0.3073730469

[576] 0.4218750000 0.7346191406 0.8276367188 0.4548339844 0.8544921875

[581] 0.8117675781 0.4711914062 0.8991699219 0.3964843750 0.5607910156

[586] 0.0991210938 0.3903808594 0.7978515625 0.7316894531 0.4614257812

[591] 0.6784667969 0.8085937500 0.0744628906 0.3081054688 0.5134277344

[596] 0.1787109375 0.3391113281 0.3891601562 0.6452636719 0.6582031250

[601] 0.2756347656 0.4545898438 0.8239746094 0.9970703125 0.6340332031

[606] 0.2543945312 0.7995605469 0.9453125000 0.1643066406 0.5385742188

[611] 0.3220214844 0.2529296875 0.6164550781 0.0571289062 0.1413574219

[616] 0.6699218750 0.7404785156 0.5600585938 0.0075683594 0.9462890625

[621] 0.2863769531 0.7973632812 0.6706542969 0.8320312500 0.0041503906

[626] 0.5190429688 0.8806152344 0.0771484375 0.6437988281 0.4750976562

[631] 0.3874511719 0.4316406250 0.9553222656 0.4155273438 0.9411621094

[636] 0.6455078125 0.6887207031 0.0903320312 0.2917480469 0.4687500000

[641] 0.5939941406 0.2495117188 0.1892089844 0.6513671875 0.4211425781

[646] 0.6430664062 0.3835449219 0.9433593750 0.9201660156 0.0209960938

[651] 0.6247558594 0.0947265625 0.8410644531 0.1333007812 0.6628417969

[656] 0.8554687500 0.9338378906 0.7299804688 0.2478027344 0.9755859375

[661] 0.9484863281 0.5610351562 0.1296386719 0.2050781250 0.6350097656

[666] 0.3764648438 0.0583496094 0.2939453125 0.7434082031 0.9262695312

[671] 0.7839355469 0.9921875000 0.0236816406 0.9604492188 0.0563964844

[676] 0.0498046875 0.2258300781 0.2290039062 0.6257324219 0.2167968750

[681] 0.0998535156 0.4819335938 0.2419433594 0.2431640625 0.3957519531

[686] 0.4692382812 0.6550292969 0.8789062500 0.8635253906 0.9409179688

[691] 0.6149902344 0.8740234375 0.2531738281 0.6469726562 0.8718261719


[696] 0.9785156250 0.3146972656 0.3374023438 0.1755371094 0.9423828125

[701] 0.7980957031 0.7622070312 0.2761230469 0.5156250000 0.4533691406

[706] 0.6713867188 0.9235839844 0.4482421875 0.0305175781 0.8149414062

[711] 0.8679199219 0.4902343750 0.2795410156 0.9428710938 0.8591308594

[716] 0.3916015625 0.9504394531 0.8051757812 0.6472167969 0.9023437500

[721] 0.7932128906 0.1518554688 0.9821777344 0.7724609375 0.5578613281

[726] 0.7329101562 0.6140136719 0.7519531250 0.9943847656 0.2983398438

[731] 0.2927246094 0.5908203125 0.8527832031 0.5981445312 0.7683105469

[736] 0.0390625000 0.8830566406 0.3823242188 0.7907714844 0.8466796875

[741] 0.8352050781 0.4008789062 0.1101074219 0.7636718750 0.4592285156

[746] 0.4038085938 0.4763183594 0.5400390625 0.5051269531 0.1411132812

[751] 0.6394042969 0.9257812500 0.7229003906 0.3627929688 0.3493652344

[756] 0.6708984375 0.8625488281 0.8188476562 0.3562011719 0.5253906250

[761] 0.6740722656 0.2592773438 0.4099121094 0.2392578125 0.9074707031

[766] 0.4340820312 0.2604980469 0.5625000000 0.3127441406 0.0932617188

[771] 0.6579589844 0.2451171875 0.6398925781 0.9868164062 0.3522949219

[776] 0.0371093750 0.6389160156 0.8647460938 0.0935058594 0.6884765625

[781] 0.0598144531 0.4770507812 0.6315917969 0.9492187500 0.6525878906

[786] 0.5737304688 0.7165527344 0.5693359375 0.1672363281 0.9047851562

[791] 0.0983886719 0.2988281250 0.3537597656 0.2202148438 0.5270996094

[796] 0.8876953125 0.9621582031 0.2700195312 0.7526855469 0.0859375000

[801] 0.7424316406 0.8041992188 0.5251464844 0.6435546875 0.4445800781

[806] 0.5727539062 0.5944824219 0.3105468750 0.8186035156 0.3256835938

[811] 0.7106933594 0.8369140625 0.6145019531 0.8129882812 0.6237792969

[816] 0.9726562500 0.5822753906 0.7846679688 0.0837402344 0.4677734375

[821] 0.4719238281 0.9907226562 0.8405761719 0.0722656250 0.0334472656

[826] 0.1811523438 0.6442871094 0.5361328125 0.0168457031 0.1059570312

[831] 0.2448730469 0.6093750000 0.1721191406 0.5151367188 0.3923339844

[836] 0.0419921875 0.2492675781 0.1586914062 0.8366699219 0.5839843750

[841] 0.9982910156 0.7866210938 0.3278808594 0.9853515625 0.1691894531

[846] 0.1489257812 0.6159667969 0.9960937500 0.5119628906 0.9956054688


[851] 0.4509277344 0.3662109375 0.7766113281 0.0766601562 0.5827636719

[856] 0.8457031250 0.7131347656 0.1420898438 0.7614746094 0.1845703125

[861] 0.0715332031 0.9418945312 0.7370605469 0.1328125000 0.6018066406

[866] 0.2260742188 0.2595214844 0.4404296875 0.0539550781 0.7446289062

[871] 0.0788574219 0.8574218750 0.1779785156 0.2475585938 0.9450683594

[876] 0.1337890625 0.7238769531 0.4848632812 0.6081542969 0.0195312500

[881] 0.4416503906 0.2065429688 0.8181152344 0.2646484375 0.0812988281

[886] 0.1625976562 0.3249511719 0.6191406250 0.3928222656 0.1030273438

[891] 0.8786621094 0.8330078125 0.1262207031 0.7778320312 0.2292480469

[896] 0.6562500000 0.0314941406 0.9370117188 0.1267089844 0.8388671875

[901] 0.8586425781 0.3305664062 0.3210449219 0.1308593750 0.3576660156

[906] 0.7084960938 0.5622558594 0.2822265625 0.2785644531 0.8208007812

[911] 0.6003417969 0.0429687500 0.3713378906 0.4174804688 0.1853027344

[916] 0.1630859375 0.3859863281 0.2485351562 0.0671386719 0.3925781250

[921] 0.0725097656 0.0639648438 0.9958496094 0.4814453125 0.1809082031

[926] 0.6137695312 0.7214355469 0.1796875000 0.4611816406 0.6479492188

[931] 0.9938964844 0.2373046875 0.6633300781 0.9165039062 0.5632324219

[936] 0.4042968750 0.5373535156 0.1694335938 0.1794433594 0.4306640625

[941] 0.8332519531 0.1567382812 0.5925292969 0.0664062500 0.3010253906

[946] 0.6284179688 0.5524902344 0.0615234375 0.6906738281 0.3344726562

[951] 0.8093261719 0.1660156250 0.7521972656 0.0249023438 0.1130371094

[956] 0.1298828125 0.2355957031 0.4497070312 0.2136230469 0.7031250000

[961] 0.8908691406 0.3588867188 0.8610839844 0.6357421875 0.4680175781

[966] 0.5024414062 0.8054199219 0.6777343750 0.7170410156 0.6303710938

[971] 0.7966308594 0.5791015625 0.3879394531 0.4926757812 0.5847167969

[976] 0.0898437500 0.2307128906 0.8393554688 0.9196777344 0.9599609375

[981] 0.9953613281 0.4204101562 0.5515136719 0.9394531250 0.4318847656

[986] 0.9858398438 0.2302246094 0.7783203125 0.2902832031 0.2856445312

[991] 0.7058105469 0.2265625000 0.3205566406 0.0698242188 0.7282714844

[996] 0.0341796875 0.2727050781 0.0883789062 0.0476074219 0.9511718750


> #initialize all parameters to zero

> n1=0;n2=0;n3=0;n4=0;n5=0;n6=0;n7=0;n8=0;n9=0;n10=0

> n=1000;n

[1] 1000

> x=z$U;x

[1] 0.0002441406 0.0307617188 0.8454589844 0.6826171875 0.3273925781

[6] 0.9243164062 0.5397949219 0.4746093750 0.3264160156 0.8022460938

[11] 0.2810058594 0.1259765625 0.7473144531 0.4145507812 0.8190917969

[16] 0.3867187500 0.3400878906 0.5112304688 0.9040527344 0.0068359375

[21] 0.8547363281 0.8422851562 0.2858886719 0.7363281250 0.0412597656

[26] 0.1577148438 0.7145996094 0.3251953125 0.6496582031 0.2075195312

[31] 0.9401855469 0.5234375000 0.4299316406 0.7416992188 0.7126464844

[36] 0.0810546875 0.1320800781 0.5102539062 0.7819824219 0.7480468750

[41] 0.5061035156 0.2631835938 0.8981933594 0.2744140625 0.3020019531

[46] 0.7504882812 0.8112792969 0.4101562500 0.2697753906 0.7221679688

[51] 0.2712402344 0.9052734375 0.1594238281 0.9282226562 0.0280761719

[56] 0.5097656250 0.7209472656 0.1186523438 0.8317871094 0.9736328125

[61] 0.7043457031 0.0434570312 0.4323730469 0.0468750000 0.8596191406

[66] 0.4526367188 0.5798339844 0.4794921875 0.9367675781 0.0961914062

[71] 0.0241699219 0.0214843750 0.6857910156 0.7241210938 0.5153808594

[76] 0.4228515625 0.8566894531 0.0864257812 0.8034667969 0.4335937500

[81] 0.1994628906 0.9331054688 0.6384277344 0.8037109375 0.4641113281

[86] 0.0141601562 0.7702636719 0.2832031250 0.4006347656 0.0795898438

[91] 0.9489746094 0.6220703125 0.7590332031 0.8793945312 0.9245605469

[96] 0.5703125000 0.2893066406 0.1635742188 0.4470214844 0.8779296875

[101] 0.7414550781 0.6821289062 0.2663574219 0.2949218750 0.8654785156

[106] 0.1850585938 0.1325683594 0.5712890625 0.4113769531 0.4223632812

[111] 0.7956542969 0.4570312500 0.1291503906 0.1440429688 0.0056152344

[116] 0.7021484375 0.7687988281 0.1000976562 0.5124511719 0.0566406250

[121] 0.0803222656 0.0405273438 0.0661621094 0.2705078125 0.8137207031

[126] 0.7153320312 0.4167480469 0.0937500000 0.7189941406 0.8745117188


[131] 0.3142089844 0.2763671875 0.5461425781 0.2680664062 0.5085449219

[136] 0.5683593750 0.0451660156 0.6459960938 0.7497558594 0.7197265625

[141] 0.9660644531 0.7583007812 0.7878417969 0.4804687500 0.0588378906

[146] 0.3549804688 0.3728027344 0.6005859375 0.0734863281 0.1860351562

[151] 0.2546386719 0.8300781250 0.7600097656 0.0014648438 0.1833496094

[156] 0.9189453125 0.8684082031 0.5512695312 0.9089355469 0.6171875000

[161] 0.1486816406 0.5854492188 0.1813964844 0.6748046875 0.3508300781

[166] 0.8540039062 0.7507324219 0.8417968750 0.2248535156 0.1069335938

[171] 0.3669433594 0.8681640625 0.5207519531 0.0942382812 0.7800292969

[176] 0.5039062500 0.9885253906 0.5659179688 0.7399902344 0.4990234375

[181] 0.3781738281 0.2719726562 0.9968261719 0.6035156250 0.4396972656

[186] 0.9624023438 0.3005371094 0.5673828125 0.9230957031 0.3872070312

[191] 0.4011230469 0.1406250000 0.5783691406 0.2963867188 0.0485839844

[196] 0.0732421875 0.1555175781 0.4399414062 0.9929199219 0.1152343750

[201] 0.4045410156 0.5678710938 0.9841308594 0.0166015625 0.0754394531

[206] 0.4301757812 0.7722167969 0.5273437500 0.9182128906 0.7768554688

[211] 0.1071777344 0.3974609375 0.6828613281 0.3579101562 0.7390136719

[216] 0.3769531250 0.1193847656 0.9233398438 0.4177246094 0.2158203125

[221] 0.9777832031 0.2231445312 0.8933105469 0.6640625000 0.0080566406

[226] 0.0073242188 0.9157714844 0.4716796875 0.9602050781 0.0258789062

[231] 0.2351074219 0.3886718750 0.5842285156 0.0288085938 0.6013183594

[236] 0.1650390625 0.6301269531 0.7661132812 0.7644042969 0.5507812500

[241] 0.8479003906 0.9877929688 0.4743652344 0.2958984375 0.9875488281

[246] 0.4438476562 0.4812011719 0.1503906250 0.7990722656 0.8842773438

[251] 0.5349121094 0.8642578125 0.0324707031 0.0590820312 0.3854980469

[256] 0.1875000000 0.4377441406 0.7182617188 0.7829589844 0.8701171875

[261] 0.7648925781 0.6118164062 0.4772949219 0.6621093750 0.7639160156

[266] 0.4897460938 0.2185058594 0.3134765625 0.1848144531 0.1020507812

[271] 0.7565917969 0.5742187500 0.7775878906 0.1987304688 0.8415527344

[276] 0.1943359375 0.2922363281 0.5297851562 0.2233886719 0.9238281250

[281] 0.4787597656 0.8452148438 0.6520996094 0.5126953125 0.0871582031


[286] 0.8950195312 0.8776855469 0.7109375000 0.8674316406 0.4291992188

[291] 0.6501464844 0.2685546875 0.5695800781 0.1977539062 0.7194824219

[296] 0.9355468750 0.9436035156 0.9506835938 0.8356933594 0.4619140625

[301] 0.7395019531 0.4379882812 0.7487792969 0.5976562500 0.7072753906

[306] 0.4096679688 0.2087402344 0.0927734375 0.5969238281 0.6157226562

[311] 0.9655761719 0.6972656250 0.1584472656 0.8061523438 0.7692871094

[316] 0.1611328125 0.1418457031 0.7309570312 0.3698730469 0.2343750000

[321] 0.2971191406 0.1401367188 0.5173339844 0.6669921875 0.3742675781

[326] 0.7836914062 0.9616699219 0.2089843750 0.1232910156 0.4116210938

[331] 0.4528808594 0.6103515625 0.2941894531 0.7739257812 0.7409667969

[336] 0.6210937500 0.6369628906 0.6206054688 0.5759277344 0.9912109375

[341] 0.9016113281 0.7016601562 0.7077636719 0.4707031250 0.8381347656

[346] 0.7670898438 0.8864746094 0.8095703125 0.1965332031 0.5668945312

[351] 0.8620605469 0.7578125000 0.7268066406 0.8510742188 0.3845214844

[356] 0.0654296875 0.1789550781 0.3696289062 0.2038574219 0.4824218750

[361] 0.3029785156 0.8725585938 0.0700683594 0.7587890625 0.8488769531

[366] 0.1098632812 0.7331542969 0.6445312500 0.5666503906 0.8315429688

[371] 0.9431152344 0.8896484375 0.2062988281 0.7875976562 0.4499511719

[376] 0.2441406250 0.5178222656 0.7280273438 0.0036621094 0.4580078125

[381] 0.2512207031 0.4028320312 0.3542480469 0.2812500000 0.1564941406

[386] 0.5620117188 0.2517089844 0.4638671875 0.9836425781 0.9555664062

[391] 0.4460449219 0.7558593750 0.4826660156 0.3334960938 0.6872558594

[396] 0.9072265625 0.4035644531 0.4458007812 0.7253417969 0.6679687500

[401] 0.4963378906 0.0424804688 0.3103027344 0.7880859375 0.5109863281

[406] 0.8735351562 0.1921386719 0.0175781250 0.1975097656 0.6889648438

[411] 0.1208496094 0.1064453125 0.3059082031 0.2387695312 0.8464355469

[416] 0.8046875000 0.5861816406 0.2729492188 0.1188964844 0.8623046875

[421] 0.7883300781 0.5415039062 0.6882324219 0.0292968750 0.6623535156

[426] 0.7944335938 0.3044433594 0.0556640625 0.9582519531 0.7817382812

[431] 0.7175292969 0.6914062500 0.4260253906 0.2534179688 0.6774902344

[436] 0.6865234375 0.8156738281 0.9594726562 0.9343261719 0.7910156250


[441] 0.8771972656 0.6499023438 0.2380371094 0.7548828125 0.3605957031

[446] 0.0747070312 0.3386230469 0.3281250000 0.0158691406 0.9838867188

[451] 0.9860839844 0.2607421875 0.5930175781 0.1274414062 0.9304199219

[456] 0.3027343750 0.8420410156 0.2553710938 0.9216308594 0.2041015625

[461] 0.5129394531 0.1176757812 0.7097167969 0.7148437500 0.3557128906

[466] 0.4643554688 0.0446777344 0.5849609375 0.1203613281 0.0454101562

[471] 0.6765136719 0.5644531250 0.5568847656 0.6108398438 0.3552246094

[476] 0.4033203125 0.4152832031 0.9106445312 0.8308105469 0.8515625000

[481] 0.4455566406 0.6948242188 0.8532714844 0.6591796875 0.3977050781

[486] 0.7133789062 0.1726074219 0.5761718750 0.0217285156 0.7163085938

[491] 0.5388183594 0.3525390625 0.0676269531 0.4536132812 0.7019042969

[496] 0.7382812500 0.2854003906 0.6752929688 0.4118652344 0.4833984375

[501] 0.4250488281 0.1313476562 0.4187011719 0.3378906250 0.2365722656

[506] 0.5717773438 0.4724121094 0.0517578125 0.4699707031 0.7465820312

[511] 0.3229980469 0.3750000000 0.8752441406 0.4057617188 0.7204589844

[516] 0.0576171875 0.2023925781 0.2993164062 0.4147949219 0.8496093750

[521] 0.2014160156 0.1772460938 0.1560058594 0.5009765625 0.6223144531

[526] 0.7895507812 0.6940917969 0.7617187500 0.2150878906 0.8862304688

[531] 0.7790527344 0.3818359375 0.7297363281 0.2172851562 0.1608886719

[536] 0.1113281250 0.9162597656 0.5327148438 0.5895996094 0.7001953125

[541] 0.5246582031 0.5825195312 0.8151855469 0.8984375000 0.3049316406

[546] 0.1166992188 0.5876464844 0.4560546875 0.0070800781 0.8852539062

[551] 0.6569824219 0.1230468750 0.3811035156 0.6381835938 0.7731933594

[556] 0.6494140625 0.1770019531 0.1254882812 0.6862792969 0.7851562500

[561] 0.1447753906 0.0971679688 0.1462402344 0.2802734375 0.0344238281

[566] 0.3032226562 0.9030761719 0.8847656250 0.5959472656 0.4936523438

[571] 0.7067871094 0.3486328125 0.5793457031 0.4184570312 0.3073730469

[576] 0.4218750000 0.7346191406 0.8276367188 0.4548339844 0.8544921875

[581] 0.8117675781 0.4711914062 0.8991699219 0.3964843750 0.5607910156

[586] 0.0991210938 0.3903808594 0.7978515625 0.7316894531 0.4614257812

[591] 0.6784667969 0.8085937500 0.0744628906 0.3081054688 0.5134277344


[596] 0.1787109375 0.3391113281 0.3891601562 0.6452636719 0.6582031250

[601] 0.2756347656 0.4545898438 0.8239746094 0.9970703125 0.6340332031

[606] 0.2543945312 0.7995605469 0.9453125000 0.1643066406 0.5385742188

[611] 0.3220214844 0.2529296875 0.6164550781 0.0571289062 0.1413574219

[616] 0.6699218750 0.7404785156 0.5600585938 0.0075683594 0.9462890625

[621] 0.2863769531 0.7973632812 0.6706542969 0.8320312500 0.0041503906

[626] 0.5190429688 0.8806152344 0.0771484375 0.6437988281 0.4750976562

[631] 0.3874511719 0.4316406250 0.9553222656 0.4155273438 0.9411621094

[636] 0.6455078125 0.6887207031 0.0903320312 0.2917480469 0.4687500000

[641] 0.5939941406 0.2495117188 0.1892089844 0.6513671875 0.4211425781

[646] 0.6430664062 0.3835449219 0.9433593750 0.9201660156 0.0209960938

[651] 0.6247558594 0.0947265625 0.8410644531 0.1333007812 0.6628417969

[656] 0.8554687500 0.9338378906 0.7299804688 0.2478027344 0.9755859375

[661] 0.9484863281 0.5610351562 0.1296386719 0.2050781250 0.6350097656

[666] 0.3764648438 0.0583496094 0.2939453125 0.7434082031 0.9262695312

[671] 0.7839355469 0.9921875000 0.0236816406 0.9604492188 0.0563964844

[676] 0.0498046875 0.2258300781 0.2290039062 0.6257324219 0.2167968750

[681] 0.0998535156 0.4819335938 0.2419433594 0.2431640625 0.3957519531

[686] 0.4692382812 0.6550292969 0.8789062500 0.8635253906 0.9409179688

[691] 0.6149902344 0.8740234375 0.2531738281 0.6469726562 0.8718261719

[696] 0.9785156250 0.3146972656 0.3374023438 0.1755371094 0.9423828125

[701] 0.7980957031 0.7622070312 0.2761230469 0.5156250000 0.4533691406

[706] 0.6713867188 0.9235839844 0.4482421875 0.0305175781 0.8149414062

[711] 0.8679199219 0.4902343750 0.2795410156 0.9428710938 0.8591308594

[716] 0.3916015625 0.9504394531 0.8051757812 0.6472167969 0.9023437500

[721] 0.7932128906 0.1518554688 0.9821777344 0.7724609375 0.5578613281

[726] 0.7329101562 0.6140136719 0.7519531250 0.9943847656 0.2983398438

[731] 0.2927246094 0.5908203125 0.8527832031 0.5981445312 0.7683105469

[736] 0.0390625000 0.8830566406 0.3823242188 0.7907714844 0.8466796875

[741] 0.8352050781 0.4008789062 0.1101074219 0.7636718750 0.4592285156

[746] 0.4038085938 0.4763183594 0.5400390625 0.5051269531 0.1411132812


[751] 0.6394042969 0.9257812500 0.7229003906 0.3627929688 0.3493652344

[756] 0.6708984375 0.8625488281 0.8188476562 0.3562011719 0.5253906250

[761] 0.6740722656 0.2592773438 0.4099121094 0.2392578125 0.9074707031

[766] 0.4340820312 0.2604980469 0.5625000000 0.3127441406 0.0932617188

[771] 0.6579589844 0.2451171875 0.6398925781 0.9868164062 0.3522949219

[776] 0.0371093750 0.6389160156 0.8647460938 0.0935058594 0.6884765625

[781] 0.0598144531 0.4770507812 0.6315917969 0.9492187500 0.6525878906

[786] 0.5737304688 0.7165527344 0.5693359375 0.1672363281 0.9047851562

[791] 0.0983886719 0.2988281250 0.3537597656 0.2202148438 0.5270996094

[796] 0.8876953125 0.9621582031 0.2700195312 0.7526855469 0.0859375000

[801] 0.7424316406 0.8041992188 0.5251464844 0.6435546875 0.4445800781

[806] 0.5727539062 0.5944824219 0.3105468750 0.8186035156 0.3256835938

[811] 0.7106933594 0.8369140625 0.6145019531 0.8129882812 0.6237792969

[816] 0.9726562500 0.5822753906 0.7846679688 0.0837402344 0.4677734375

[821] 0.4719238281 0.9907226562 0.8405761719 0.0722656250 0.0334472656

[826] 0.1811523438 0.6442871094 0.5361328125 0.0168457031 0.1059570312

[831] 0.2448730469 0.6093750000 0.1721191406 0.5151367188 0.3923339844

[836] 0.0419921875 0.2492675781 0.1586914062 0.8366699219 0.5839843750

[841] 0.9982910156 0.7866210938 0.3278808594 0.9853515625 0.1691894531

[846] 0.1489257812 0.6159667969 0.9960937500 0.5119628906 0.9956054688

[851] 0.4509277344 0.3662109375 0.7766113281 0.0766601562 0.5827636719

[856] 0.8457031250 0.7131347656 0.1420898438 0.7614746094 0.1845703125

[861] 0.0715332031 0.9418945312 0.7370605469 0.1328125000 0.6018066406

[866] 0.2260742188 0.2595214844 0.4404296875 0.0539550781 0.7446289062

[871] 0.0788574219 0.8574218750 0.1779785156 0.2475585938 0.9450683594

[876] 0.1337890625 0.7238769531 0.4848632812 0.6081542969 0.0195312500

[881] 0.4416503906 0.2065429688 0.8181152344 0.2646484375 0.0812988281

[886] 0.1625976562 0.3249511719 0.6191406250 0.3928222656 0.1030273438

[891] 0.8786621094 0.8330078125 0.1262207031 0.7778320312 0.2292480469

[896] 0.6562500000 0.0314941406 0.9370117188 0.1267089844 0.8388671875

[901] 0.8586425781 0.3305664062 0.3210449219 0.1308593750 0.3576660156


[906] 0.7084960938 0.5622558594 0.2822265625 0.2785644531 0.8208007812

[911] 0.6003417969 0.0429687500 0.3713378906 0.4174804688 0.1853027344

[916] 0.1630859375 0.3859863281 0.2485351562 0.0671386719 0.3925781250

[921] 0.0725097656 0.0639648438 0.9958496094 0.4814453125 0.1809082031

[926] 0.6137695312 0.7214355469 0.1796875000 0.4611816406 0.6479492188

[931] 0.9938964844 0.2373046875 0.6633300781 0.9165039062 0.5632324219

[936] 0.4042968750 0.5373535156 0.1694335938 0.1794433594 0.4306640625

[941] 0.8332519531 0.1567382812 0.5925292969 0.0664062500 0.3010253906

[946] 0.6284179688 0.5524902344 0.0615234375 0.6906738281 0.3344726562

[951] 0.8093261719 0.1660156250 0.7521972656 0.0249023438 0.1130371094

[956] 0.1298828125 0.2355957031 0.4497070312 0.2136230469 0.7031250000

[961] 0.8908691406 0.3588867188 0.8610839844 0.6357421875 0.4680175781

[966] 0.5024414062 0.8054199219 0.6777343750 0.7170410156 0.6303710938

[971] 0.7966308594 0.5791015625 0.3879394531 0.4926757812 0.5847167969

[976] 0.0898437500 0.2307128906 0.8393554688 0.9196777344 0.9599609375

[981] 0.9953613281 0.4204101562 0.5515136719 0.9394531250 0.4318847656

[986] 0.9858398438 0.2302246094 0.7783203125 0.2902832031 0.2856445312

[991] 0.7058105469 0.2265625000 0.3205566406 0.0698242188 0.7282714844

[996] 0.0341796875 0.2727050781 0.0883789062 0.0476074219 0.9511718750

> for(i in 1:n)

+{

+ if(x[i]<0.1){n1=n1+1}

+ if((x[i]>=0.1)&&(x[i]<0.2)){n2=n2+1}

+ if((x[i]>=0.2)&&(x[i]<0.3)){n3=n3+1}

+ if((x[i]>=0.3)&&(x[i]<0.4)){n4=n4+1}

+ if((x[i]>=0.4)&&(x[i]<0.5)){n5=n5+1}

+ if((x[i]>=0.5)&&(x[i]<0.6)){n6=n6+1}

+ if((x[i]>=0.6)&&(x[i]<0.7)){n7=n7+1}

+ if((x[i]>=0.7)&&(x[i]<0.8)){n8=n8+1}

+ if((x[i]>=0.8)&&(x[i]<0.9)){n9=n9+1}

+ if((x[i]>=0.9)&&(x[i]<1.0)){n10=n10+1}
+}

>

> ofreq=c(n1,n2,n3,n4,n5,n6,n7,n8,n9,n10);ofreq

[1] 101 96 98 85 105 93 97 125 106 94

> N=sum(ofreq);N

[1] 1000

> k=length(ofreq);k

[1] 10

> p=1/k;p

[1] 0.1

> efreq=rep(N*p);efreq

[1] 100

> los=0.05;

> cat("using goodness of fit test","\n");

using goodness of fit test

> cat("To test:H0:Generated random numbers follow U(0,1) Against H1:Generated random numbers
do not follow U(0,1)\n");

To test:H0:Generated random numbers follow U(0,1) Against H1:Generated random numbers do not
follow U(0,1)

> Tcal=sum(((ofreq-efreq)^2)/efreq);Tcal

[1] 10.26

> pv=pchisq(Tcal,df=(k-1),lower.tail=F);

> cat("computed test statistic:",Tcal,"\n");

computed test statistic: 10.26

> cat("pvalue:",pv,"\n");

pvalue: 0.3298498

> los1=100*los;

> if(pv<los){cat("Since,pv<los Reject H0 at",los1,"% level of significance\n");}else{cat("since


pv>los,Accept H0");}

since pv>los,Accept H0>

***********************************************************************
#Q7

> lcg<-function(a,c,m,run.length,seed)

+{

+ x<-rep(0,run.length)

+ x[1]<-seed

+ for(i in 1:(run.length-1))

+{

+ x[i+1]<-(a*x[i]+c)%%m

+}

+ U<-x/m

+ return(list(x=x,U=U))

+}

>

> z=lcg(1103515245,12345,2^32,30,7);z

$x

[1] 7 3429651764 642666496 196624384 2700308544 3311041536

[7] 2169437184 124353536 867302464 2535724800 593492992 916880384

[13] 3869965312 932543488 510524416 1604090944 3170670336 932084736

[19] 4185062400 649952256 578157568 2265218048 3266378752 3122887680

[25] 4175690752 1473936384 3788438528 501840896 3358719040 3517192192

$U

[1] 1.629815e-09 7.985280e-01 1.496325e-01 4.578018e-02 6.287146e-01

[6] 7.709119e-01 5.051115e-01 2.895331e-02 2.019346e-01 5.903944e-01

[11] 1.381834e-01 2.134778e-01 9.010465e-01 2.171247e-01 1.188657e-01

[16] 3.734815e-01 7.382292e-01 2.170179e-01 9.744108e-01 1.513288e-01

[21] 1.346128e-01 5.274122e-01 7.605131e-01 7.271039e-01 9.722288e-01

[26] 3.431776e-01 8.820646e-01 1.168439e-01 7.820127e-01 8.189101e-01

> los=0.05;los
[1] 0.05

> rt=ks.test(z$U,"punif",0,1);rt

One-sample Kolmogorov-Smirnov test

data: z$U

D = 0.21621, p-value = 0.1037

alternative hypothesis: two-sided

> Tcal=rt$statistic;Tcal

0.2162086

> pv=rt$p.value;pv

[1] 0.1037274

> cat("Using Kolmogorov - smirnov test ","\n")

Using Kolmogorov - smirnov test

> cat("H0:sample has been drawn from uniform distribution over (0,1) Against H1:sample has not
been drawn from uniform distribution over (0,1)","\n");

H0:sample has been drawn from uniform distribution over (0,1) Against H1:sample has not been
drawn from uniform distribution over (0,1)

> cat("computed test Statistic=",Tcal,"\n")

computed test Statistic= 0.2162086

> cat("p value=",pv,"\n")

p value= 0.1037274

> if(pv<los){cat("Since,pv <los Reject H0 at",los1,"%level of significance\n");}else{cat("since


pv>los,Accept H0 at",los1,"% level of significance\n");}

since pv>los,Accept H0 at 5 % level of significance

***************************************************************************

You might also like