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