Shapiro-Wilk test implemented in

79 次查看(过去 30 天)
I realize that several hypothesis (distribution) tests are implemented in the Statistics and Machine Learning Toolbox. However, I can not find the Shapiro-Wilk Test (e.g. swtest). Is there a reliable implementation out there, or it can be found under another name?

回答(1 个)

Hugo Pecho Chipa
Hugo Pecho Chipa 2020-8-16
% ----------------------- PRUEBA DE NORMALIDAD SHAPIRO-WILK --------------
% Tabla de coeficientes "ai" hasta un máximo de 30 valores n = horizontal,
% pares = vertical
tabla1 = [0 0.7071 0.7071 0.6872 0.6646 0.6431 0.6233 0.6052 0.5888 0.5739 0.5601 0.5475 0.5359 0.5251 0.515 0.5056 0.4968 0.4886 0.4808 0.4734 0.4643 0.459 0.4542 0.4493 0.445 0.4407 0.4366 0.4328 0.4291 0.4254
0 0 0 0.1677 0.2413 0.2806 0.3031 0.3164 0.3244 0.3291 0.3315 0.3325 0.3325 0.3318 0.3306 0.329 0.3273 0.3253 0.3232 0.3211 0.3185 0.3156 0.3126 0.3098 0.3069 0.3043 0.3018 0.2992 0.2968 0.2944
0 0 0 0 0 0.0875 0.1401 0.1743 0.1976 0.2141 0.226 0.2347 0.2412 0.2495 0.2495 0.2521 0.254 0.2553 0.2561 0.2565 0.2578 0.2571 0.2563 0.2554 0.2543 0.2533 0.2522 0.251 0.2499 0.2487
0 0 0 0 0 0 0 0,0561 0,0947 0,1224 0,1429 0,1586 0,1707 0,1802 0,1878 0,1988 0,1988 0,2027 0,2059 0,2085 0,2119 0,2131 0,2139 0,2145 0,2148 0,2151 0,2152 0,2151 0,215 0,2148
0 0 0 0 0 0 0 0 0 0.0399 0.0695 0.0922 0.1099 0.124 0.1353 0.1447 0.1524 0.1587 0.1641 0.1686 0.1736 0.1764 0.1787 0.1807 0.1822 0.1836 0.1848 0.1857 0.1864 0.187
0 0 0 0 0 0 0 0 0 0 0 0.0303 0.0539 0.0727 0.088 0.1005 0.1109 0.1197 0.1271 0.1334 0.1399 0.1443 0.148 0.1512 0.1539 0.1563 0.1584 0.1601 0.1616 0.163
0 0 0 0 0 0 0 0 0 0 0 0 0.024 0.0433 0.0593 0.0725 0.0837 0.0932 0.1013 0.1092 0.115 0.1201 0.1245 0.1283 0.1316 0.1346 0.1372 0.1395 0.1415
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.0196 0.0359 0.0496 0.0612 0.0711 0.0804 0.0878 0.0941 0.0997 0.1046 0.1089 0.1128 0.1162 0.1192 0.1219
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.0163 0.0303 0.0422 0.053 0.0618 0.0696 0.0764 0.0823 0.0876 0.0923 0.0965 0.1002 0.1036
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0,014 0,0263 0,0368 0,0459 0,0539 0,061 0,0672 0,0728 0,0778 0,0822 0,0862
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0,0122 0,0228 0,0321 0,0403 0,0476 0,054 0,0598 0,065 0,0697
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0,0107 0,02 0,0284 0,0358 0,0424 0,0483 0,0537
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0,0094 0,0178 0,0253 0,032 0,0381
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0,0084 0,0159 0,0227
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.0076]
% Tabla de distribución la columa 3 representa un alfa = 0.05 o 5% y las
% filas representan el número de valores "n"
tabla2 = [0,753 0,756 0,767
0,687 0,707 0,748
0,686 0,715 0,762
0,713 0,743 0,788
0,730 0,760 0,803
0,749 0,780 0,818
0,764 0,791 0,829
0,781 0,806 0,842
0,792 0,817 0,850
0,805 0,828 0,859
0,814 0,837 0,866
0,825 0,846 0,874
0,835 0,855 0,881
0,844 0,863 0,887
0,851 0,869 0,892
0,858 0,874 0,897
0,863 0,879 0,901
0,868 0,884 0,905
0,873 0,888 0,908
0,878 0,892 0,911
0,881 0,895 0,914
0,884 0,898 0,916
0,888 0,901 0,918
0,891 0,904 0,920
0,894 0,906 0,923
0,896 0,908 0,924
0,898 0,910 0,926
0,900 0,912 0,927]
% Pasos para obtener el W = estadístico y el VC = valor crítico
a = [2; 4; 6; 8; 10; 12; 14; dieciséis; 18; 20];
b = [6,55; 5,58; 4,33; 2,53; 5,49; 8,64; 7,54; 5,5; 2,6; 2,33];
x = [a, b]; % Insertamos valores
dimensiones = tamaño (x);
columnas = dimensiones (1,2);
x = sort (x, 'ascender'); % Ordenamos valores
n = longitud (x); % n = número de valores
pares = n / 2
ai = tabla1 (1: pares, n); % Coeficiente según tabla 1
xma = sort (x, 'descender');
xme = sort (x, 'ascender');
xmayor = xma (1: pares, 1: columnas); % Mayores valores de x
xmenor = xme (1: pares, 1: columnas); % Menores valores de x
W = (suma (ai. * (Xmayor-xmenor))). ^ 2./sum((x-mean(x)).^2);
W = remodelar (W, columnas, 1); % Estadístico
VC = tabla2 (n, 3);
VC = repmat (VC, columnas, 1); % Valor crítico
% Resumen de datos
datos = [W, VC]
Resumen = tabla (W, VC, 'RowNames', {'Variable 1'; 'Variable 2'})
% Exportación en formato excel
% xlswrite ('shapiro', datos, 'Hoja1', 'A1')

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by