Accelerating the pace of engineering and science

# Documentation Center

• Trial Software

## Perform Shapiro-Wilk Test

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:

```stats::swGOFT(x);
stats::swGOFT(y)```