This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Perform Shapiro-Wilk Test

MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

The Shapiro-Wilk goodness-of-fit test asserts the hypothesis that the data has a normal distribution. For the Shapiro-Wilk goodness-of-fit test, MuPAD® provides the stats::swGOFT function. For example, create the normally distributed data sequence x by using the stats::normalRandom function:

fx := stats::normalRandom(0, 1/2):
x := fx() $ k = 1..1000:

Also, create the data sequence y by using the stats::poissonRandom function. This function generates random numbers according to the Poisson distribution:

fy := stats::poissonRandom(10):
y := fy() $ k = 1..1000:

Now, use the stats::swGOFT function to test whether these two sequences are normally distributed. Suppose, you use the typical significance level 0.05. For the first sequence (x), the resulting p-value is above the significance level. The entries of the sequence x can have a normal distribution. For the second sequence (y), the resulting p-value is below the significance level. Therefore, reject the hypothesis that the entries of this sequence are normally distributed:


Was this topic helpful?