4 #include "local_proto.h"
9 double a[25], s2, *xcopy;
10 double sumb = 0.0, sumx = 0.0, sumx2 = 0.0;
13 if ((xcopy = (
double *)
malloc(n *
sizeof(
double))) ==
NULL) {
14 fprintf(stderr,
"Memory error in Cdhc_shapiro_wilk\n");
19 for (i = 0; i < n; ++i) {
24 s2 = sumx2 - sumx * sumx / n;
26 qsort(xcopy, n,
sizeof(
double),
Cdhc_dcmp);
102 a[1] = (double).3306;
103 a[2] = (double).2495;
104 a[3] = (double).1878;
105 a[4] = (double).1353;
107 a[6] = (double).0433;
110 a[0] = (double).5056;
112 a[2] = (double).2521;
113 a[3] = (double).1939;
114 a[4] = (double).1447;
115 a[5] = (double).1005;
116 a[6] = (double).0593;
117 a[7] = (double).0196;
120 a[0] = (double).4968;
121 a[1] = (double).3273;
123 a[3] = (double).1988;
124 a[4] = (double).1524;
125 a[5] = (double).1109;
126 a[6] = (double).0725;
127 a[7] = (double).0359;
130 a[0] = (double).4886;
131 a[1] = (double).3253;
132 a[2] = (double).2553;
133 a[3] = (double).2027;
134 a[4] = (double).1587;
135 a[5] = (double).1197;
136 a[6] = (double).0837;
137 a[7] = (double).0496;
138 a[8] = (double).0163;
141 a[0] = (double).4808;
142 a[1] = (double).3232;
143 a[2] = (double).2561;
144 a[3] = (double).2059;
145 a[4] = (double).1641;
146 a[5] = (double).1271;
147 a[6] = (double).0932;
148 a[7] = (double).0612;
149 a[8] = (double).0303;
152 a[0] = (double).4734;
153 a[1] = (double).3211;
154 a[2] = (double).2565;
155 a[3] = (double).2085;
156 a[4] = (double).1686;
157 a[5] = (double).1334;
158 a[6] = (double).1013;
159 a[7] = (double).0711;
160 a[8] = (double).0422;
164 a[0] = (double).4643;
165 a[1] = (double).3185;
166 a[2] = (double).2578;
167 a[3] = (double).2119;
168 a[4] = (double).1736;
169 a[5] = (double).1399;
170 a[6] = (double).1092;
171 a[7] = (double).0804;
173 a[9] = (double).0263;
177 a[1] = (double).3156;
178 a[2] = (double).2571;
179 a[3] = (double).2131;
180 a[4] = (double).1764;
181 a[5] = (double).1443;
183 a[7] = (double).0878;
184 a[8] = (double).0618;
185 a[9] = (double).0368;
186 a[10] = (double).0122;
189 a[0] = (double).4542;
190 a[1] = (double).3126;
191 a[2] = (double).2563;
192 a[3] = (double).2139;
193 a[4] = (double).1787;
195 a[6] = (double).1201;
196 a[7] = (double).0941;
197 a[8] = (double).0696;
198 a[9] = (double).0459;
199 a[10] = (double).0228;
202 a[0] = (double).4493;
203 a[1] = (double).3098;
204 a[2] = (double).2554;
205 a[3] = (double).2145;
206 a[4] = (double).1807;
207 a[5] = (double).1512;
208 a[6] = (double).1245;
209 a[7] = (double).0997;
210 a[8] = (double).0764;
211 a[9] = (double).0539;
212 a[10] = (double).0321;
213 a[11] = (double).0107;
217 a[1] = (double).3069;
218 a[2] = (double).2543;
219 a[3] = (double).2148;
220 a[4] = (double).1822;
221 a[5] = (double).1539;
222 a[6] = (double).1283;
223 a[7] = (double).1046;
224 a[8] = (double).0823;
226 a[10] = (double).0403;
230 a[0] = (double).4407;
231 a[1] = (double).3043;
232 a[2] = (double).2533;
233 a[3] = (double).2151;
234 a[4] = (double).1836;
235 a[5] = (double).1563;
236 a[6] = (double).1316;
237 a[7] = (double).1089;
238 a[8] = (double).0876;
239 a[9] = (double).0672;
240 a[10] = (double).0476;
241 a[11] = (double).0284;
242 a[12] = (double).0094;
245 a[0] = (double).4366;
246 a[1] = (double).3018;
247 a[2] = (double).2522;
248 a[3] = (double).2152;
249 a[4] = (double).1848;
250 a[5] = (double).1584;
251 a[6] = (double).1346;
252 a[7] = (double).1128;
253 a[8] = (double).0923;
254 a[9] = (double).0728;
255 a[10] = (double).054;
256 a[11] = (double).0358;
257 a[12] = (double).0178;
260 a[0] = (double).4328;
261 a[1] = (double).2992;
263 a[3] = (double).2151;
264 a[4] = (double).1857;
265 a[5] = (double).1601;
266 a[6] = (double).1372;
267 a[7] = (double).1162;
268 a[8] = (double).0965;
269 a[9] = (double).0778;
270 a[10] = (double).0598;
271 a[11] = (double).0424;
272 a[12] = (double).0253;
273 a[13] = (double).0084;
276 a[0] = (double).4291;
277 a[1] = (double).2968;
278 a[2] = (double).2499;
280 a[4] = (double).1864;
281 a[5] = (double).1616;
282 a[6] = (double).1395;
283 a[7] = (double).1192;
284 a[8] = (double).1002;
285 a[9] = (double).0822;
286 a[10] = (double).065;
287 a[11] = (double).0483;
288 a[12] = (double).032;
289 a[13] = (double).0159;
292 a[0] = (double).4254;
293 a[1] = (double).2944;
294 a[2] = (double).2487;
295 a[3] = (double).2148;
298 a[6] = (double).1415;
299 a[7] = (double).1219;
300 a[8] = (double).1036;
301 a[9] = (double).0862;
302 a[10] = (double).0697;
303 a[11] = (double).0537;
304 a[12] = (double).0381;
305 a[13] = (double).0227;
306 a[14] = (double).0076;
310 a[1] = (double).2921;
311 a[2] = (double).2475;
312 a[3] = (double).2145;
313 a[4] = (double).1874;
314 a[5] = (double).1641;
315 a[6] = (double).1433;
316 a[7] = (double).1243;
317 a[8] = (double).1066;
318 a[9] = (double).0899;
319 a[10] = (double).0739;
320 a[11] = (double).0585;
321 a[12] = (double).0435;
322 a[13] = (double).0289;
323 a[14] = (double).0144;
326 a[0] = (double).4188;
327 a[1] = (double).2898;
328 a[2] = (double).2463;
329 a[3] = (double).2141;
330 a[4] = (double).1878;
331 a[5] = (double).1651;
332 a[6] = (double).1449;
333 a[7] = (double).1265;
334 a[8] = (double).1093;
335 a[9] = (double).0931;
336 a[10] = (double).0777;
337 a[11] = (double).0629;
338 a[12] = (double).0485;
339 a[13] = (double).0344;
340 a[14] = (double).0206;
341 a[15] = (double).0068;
344 a[0] = (double).4156;
345 a[1] = (double).2876;
346 a[2] = (double).2451;
347 a[3] = (double).2137;
350 a[6] = (double).1463;
351 a[7] = (double).1284;
352 a[8] = (double).1118;
353 a[9] = (double).0961;
354 a[10] = (double).0812;
355 a[11] = (double).0669;
356 a[12] = (double).053;
357 a[13] = (double).0395;
358 a[14] = (double).0262;
359 a[15] = (double).0131;
362 a[0] = (double).4127;
363 a[1] = (double).2854;
364 a[2] = (double).2439;
365 a[3] = (double).2132;
366 a[4] = (double).1882;
367 a[5] = (double).1667;
368 a[6] = (double).1475;
369 a[7] = (double).1301;
371 a[9] = (double).0988;
372 a[10] = (double).0844;
373 a[11] = (double).0706;
374 a[12] = (double).0572;
375 a[13] = (double).0441;
376 a[14] = (double).0314;
377 a[15] = (double).0187;
378 a[16] = (double).0062;
381 a[0] = (double).4096;
382 a[1] = (double).2834;
383 a[2] = (double).2427;
384 a[3] = (double).2127;
385 a[4] = (double).1883;
386 a[5] = (double).1673;
387 a[6] = (double).1487;
388 a[7] = (double).1317;
390 a[9] = (double).1013;
391 a[10] = (double).0873;
392 a[11] = (double).0739;
393 a[12] = (double).061;
394 a[13] = (double).0484;
395 a[14] = (double).0361;
396 a[15] = (double).0239;
397 a[16] = (double).0119;
400 a[0] = (double).4068;
401 a[1] = (double).2813;
402 a[2] = (double).2415;
403 a[3] = (double).2121;
404 a[4] = (double).1883;
405 a[5] = (double).1678;
406 a[6] = (double).1496;
407 a[7] = (double).1331;
408 a[8] = (double).1179;
409 a[9] = (double).1036;
411 a[11] = (double).077;
412 a[12] = (double).0645;
413 a[13] = (double).0523;
414 a[14] = (double).0404;
415 a[15] = (double).0287;
416 a[16] = (double).0172;
417 a[17] = (double).0057;
421 a[1] = (double).2794;
422 a[2] = (double).2403;
423 a[3] = (double).2116;
424 a[4] = (double).1883;
425 a[5] = (double).1683;
426 a[6] = (double).1505;
427 a[7] = (double).1344;
428 a[8] = (double).1196;
429 a[9] = (double).1056;
430 a[10] = (double).0924;
431 a[11] = (double).0798;
432 a[12] = (double).0677;
433 a[13] = (double).0559;
434 a[14] = (double).0444;
435 a[15] = (double).0331;
436 a[16] = (double).022;
437 a[17] = (double).011;
440 a[0] = (double).4015;
441 a[1] = (double).2774;
442 a[2] = (double).2391;
444 a[4] = (double).1881;
445 a[5] = (double).1686;
446 a[6] = (double).1513;
447 a[7] = (double).1356;
448 a[8] = (double).1211;
449 a[9] = (double).1075;
450 a[10] = (double).0947;
451 a[11] = (double).0824;
452 a[12] = (double).0706;
453 a[13] = (double).0592;
454 a[14] = (double).0481;
455 a[15] = (double).0372;
456 a[16] = (double).0264;
457 a[17] = (double).0158;
458 a[18] = (double).0053;
461 a[0] = (double).3989;
462 a[1] = (double).2755;
464 a[3] = (double).2104;
466 a[5] = (double).1689;
468 a[7] = (double).1366;
469 a[8] = (double).1225;
470 a[9] = (double).1092;
471 a[10] = (double).0967;
472 a[11] = (double).0848;
473 a[12] = (double).0733;
474 a[13] = (double).0622;
475 a[14] = (double).0515;
476 a[15] = (double).0409;
477 a[16] = (double).0305;
478 a[17] = (double).0203;
479 a[18] = (double).0101;
482 a[0] = (double).3964;
483 a[1] = (double).2737;
484 a[2] = (double).2368;
485 a[3] = (double).2098;
486 a[4] = (double).1878;
487 a[5] = (double).1691;
488 a[6] = (double).1526;
489 a[7] = (double).1376;
490 a[8] = (double).1237;
491 a[9] = (double).1108;
492 a[10] = (double).0986;
493 a[11] = (double).087;
494 a[12] = (double).0759;
495 a[13] = (double).0651;
496 a[14] = (double).0546;
497 a[15] = (double).0444;
498 a[16] = (double).0343;
499 a[17] = (double).0244;
500 a[18] = (double).0146;
501 a[19] = (double).0049;
505 a[1] = (double).2719;
506 a[2] = (double).2357;
507 a[3] = (double).2091;
508 a[4] = (double).1876;
509 a[5] = (double).1693;
510 a[6] = (double).1531;
511 a[7] = (double).1384;
512 a[8] = (double).1249;
513 a[9] = (double).1123;
514 a[10] = (double).1004;
515 a[11] = (double).0891;
516 a[12] = (double).0782;
517 a[13] = (double).0677;
518 a[14] = (double).0575;
519 a[15] = (double).0476;
520 a[16] = (double).0379;
521 a[17] = (double).0283;
522 a[18] = (double).0188;
523 a[19] = (double).0094;
526 a[0] = (double).3917;
527 a[1] = (double).2701;
528 a[2] = (double).2345;
529 a[3] = (double).2085;
530 a[4] = (double).1874;
531 a[5] = (double).1694;
532 a[6] = (double).1535;
533 a[7] = (double).1392;
534 a[8] = (double).1259;
535 a[9] = (double).1136;
536 a[10] = (double).102;
537 a[11] = (double).0909;
538 a[12] = (double).0804;
539 a[13] = (double).0701;
540 a[14] = (double).0602;
541 a[15] = (double).0506;
542 a[16] = (double).0411;
543 a[17] = (double).0318;
544 a[18] = (double).0227;
545 a[19] = (double).0136;
546 a[20] = (double).0045;
549 a[0] = (double).3894;
550 a[1] = (double).2684;
551 a[2] = (double).2334;
552 a[3] = (double).2078;
553 a[4] = (double).1871;
554 a[5] = (double).1695;
555 a[6] = (double).1539;
556 a[7] = (double).1398;
557 a[8] = (double).1269;
558 a[9] = (double).1149;
559 a[10] = (double).1035;
560 a[11] = (double).0927;
561 a[12] = (double).0824;
562 a[13] = (double).0724;
563 a[14] = (double).0628;
564 a[15] = (double).0534;
565 a[16] = (double).0442;
566 a[17] = (double).0352;
567 a[18] = (double).0263;
568 a[19] = (double).0175;
569 a[20] = (double).0087;
572 a[0] = (double).3872;
573 a[1] = (double).2667;
574 a[2] = (double).2323;
575 a[3] = (double).2072;
576 a[4] = (double).1868;
577 a[5] = (double).1695;
578 a[6] = (double).1542;
579 a[7] = (double).1405;
580 a[8] = (double).1278;
582 a[10] = (double).1049;
583 a[11] = (double).0943;
584 a[12] = (double).0842;
585 a[13] = (double).0745;
586 a[14] = (double).0651;
587 a[15] = (double).056;
588 a[16] = (double).0471;
589 a[17] = (double).0383;
590 a[18] = (double).0296;
591 a[19] = (double).0211;
592 a[20] = (double).0126;
593 a[21] = (double).0042;
597 a[1] = (double).2651;
598 a[2] = (double).2313;
599 a[3] = (double).2065;
600 a[4] = (double).1865;
601 a[5] = (double).1695;
602 a[6] = (double).1545;
604 a[8] = (double).1286;
606 a[10] = (double).1062;
607 a[11] = (double).0959;
608 a[12] = (double).086;
609 a[13] = (double).0765;
610 a[14] = (double).0673;
611 a[15] = (double).0584;
612 a[16] = (double).0497;
613 a[17] = (double).0412;
614 a[18] = (double).0328;
615 a[19] = (double).0245;
616 a[20] = (double).0163;
617 a[21] = (double).0081;
621 a[1] = (double).2635;
622 a[2] = (double).2302;
623 a[3] = (double).2058;
624 a[4] = (double).1862;
625 a[5] = (double).1695;
626 a[6] = (double).1548;
627 a[7] = (double).1415;
628 a[8] = (double).1293;
630 a[10] = (double).1073;
631 a[11] = (double).0972;
632 a[12] = (double).0876;
633 a[13] = (double).0783;
634 a[14] = (double).0694;
635 a[15] = (double).0607;
636 a[16] = (double).0522;
637 a[17] = (double).0439;
638 a[18] = (double).0357;
639 a[19] = (double).0277;
640 a[20] = (double).0197;
641 a[21] = (double).0118;
642 a[22] = (double).0039;
645 a[0] = (double).3808;
647 a[2] = (double).2291;
648 a[3] = (double).2052;
649 a[4] = (double).1859;
650 a[5] = (double).1695;
654 a[9] = (double).1189;
655 a[10] = (double).1085;
656 a[11] = (double).0986;
657 a[12] = (double).0892;
658 a[13] = (double).0801;
659 a[14] = (double).0713;
660 a[15] = (double).0628;
661 a[16] = (double).0546;
662 a[17] = (double).0465;
663 a[18] = (double).0385;
664 a[19] = (double).0307;
665 a[20] = (double).0229;
666 a[21] = (double).0153;
667 a[22] = (double).0076;
670 a[0] = (double).3789;
671 a[1] = (double).2604;
672 a[2] = (double).2281;
673 a[3] = (double).2045;
674 a[4] = (double).1855;
675 a[5] = (double).1693;
676 a[6] = (double).1551;
677 a[7] = (double).1423;
678 a[8] = (double).1306;
679 a[9] = (double).1197;
680 a[10] = (double).1095;
681 a[11] = (double).0998;
682 a[12] = (double).0906;
683 a[13] = (double).0817;
684 a[14] = (double).0731;
685 a[15] = (double).0648;
686 a[16] = (double).0568;
687 a[17] = (double).0489;
688 a[18] = (double).0411;
689 a[19] = (double).0335;
690 a[20] = (double).0259;
691 a[21] = (double).0185;
692 a[22] = (double).0111;
693 a[23] = (double).0037;
697 a[1] = (double).2589;
698 a[2] = (double).2271;
699 a[3] = (double).2038;
700 a[4] = (double).1851;
701 a[5] = (double).1692;
702 a[6] = (double).1553;
703 a[7] = (double).1427;
704 a[8] = (double).1312;
705 a[9] = (double).1205;
706 a[10] = (double).1105;
707 a[11] = (double).101;
708 a[12] = (double).0919;
709 a[13] = (double).0832;
710 a[14] = (double).0748;
711 a[15] = (double).0667;
712 a[16] = (double).0588;
713 a[17] = (double).0511;
714 a[18] = (double).0436;
715 a[19] = (double).0361;
716 a[20] = (double).0288;
717 a[21] = (double).0215;
718 a[22] = (double).0143;
719 a[23] = (double).0071;
722 a[0] = (double).3751;
723 a[1] = (double).2574;
725 a[3] = (double).2032;
726 a[4] = (double).1847;
727 a[5] = (double).1691;
728 a[6] = (double).1554;
730 a[8] = (double).1317;
731 a[9] = (double).1212;
732 a[10] = (double).1113;
733 a[11] = (double).102;
734 a[12] = (double).0932;
735 a[13] = (double).0846;
736 a[14] = (double).0764;
737 a[15] = (double).0685;
738 a[16] = (double).0608;
739 a[17] = (double).0532;
740 a[18] = (double).0459;
741 a[19] = (double).0386;
742 a[20] = (double).0314;
743 a[21] = (double).0244;
744 a[22] = (double).0174;
745 a[23] = (double).0104;
746 a[24] = (double).0035;
749 if (n > 50 || n < 3) {
751 fprintf(stdout,
" THIS IS THE SHAPIRO-WILK TEST FOR SMALL SAMPLES\n");
752 fprintf(stdout,
" THE SAMPLE SIZE MUST BE LESS THAN OR EQUAL TO 50\n");
758 for (i = 1; i <= k; ++i)
759 sumb += a[i - 1] * (
x[n - i + 1] -
x[i]);
761 y[0] = sumb * sumb / s2;
765 fprintf(stdout,
" TEST13 SW(N) =%10.4f\n", y[0]);
int Cdhc_dcmp(const void *i, const void *j)
double * Cdhc_shapiro_wilk(double *x, int n)