Course contentsShow
← Data Science
Lesson 205 of 2,1456. The Normal Distribution in DepthFree lesson

Shapiro-Wilk Test

Using the Shapiro-Wilk test to formally test the null hypothesis that data comes from a normal distribution.

Shapiro-Wilk Test

You'll learn how to use a formal statistical test to decide if your data likely comes from a normal distribution.

What Is the Shapiro-Wilk Test?

The Shapiro-Wilk test is a formal hypothesis test that helps you determine whether your data is normally distributed. Unlike visual methods (histograms or Q-Q plots), this test gives you a concrete p-value to make a statistical decision.

The test evaluates:

  • Null hypothesis (H₀): The data comes from a normal distribution
  • Alternative hypothesis (H₁): The data does not come from a normal distribution

Think of it like a "referee" that examines your data and rules whether it's normal enough to pass the test.

How It Works

The Shapiro-Wilk test compares your data's order and values to what you'd expect from a perfectly normal distribution. It produces a test statistic (W) and a p-value:

  • High p-value (typically > 0.05): Fail to reject H₀ → data appears normally distributed
  • Low p-value (typically ≤ 0.05): Reject H₀ → data does not appear normally distributed

When to Use It

Use the Shapiro-Wilk test when:

  • You've already looked at Q-Q plots and want statistical confirmation
  • You need an objective decision rather than visual interpretation
  • Your sample size is small to moderate (it works best with n < 5000)

Remember: with very large datasets, even tiny deviations from normality can produce significant p-values, so always combine this test with visual assessment.

Key Takeaway: The Shapiro-Wilk test provides a formal, p-value-based method to test whether your data comes from a normal distribution, complementing visual tools like Q-Q plots.