Products
  • Wolfram|One

    The definitive Wolfram Language and notebook experience

  • Mathematica

    The original technical computing environment

  • System Modeler

    Multidomain modeling and simulation of complex systems

  • Compute ServicesUse with Mathematica and Wolfram|One
  • AI AccessUse with Mathematica and Wolfram|One
  • Finance Platform
  • Wolfram|Alpha Notebook Edition
  • Application Server
  • Enterprise Private Cloud
  • Wolfram Engine
  • Wolfram Player
  • Wolfram Cloud App
  • Wolfram Player App

More mobile apps

Wolfram|Alpha

  • Wolfram|Alpha Website
  • Wolfram|Alpha APIs

AI Products

  • Wolfram AI Ecosystem
  • Wolfram Foundation Tool
  • Wolfram Cloud MCP
  • Wolfram Local MCP
  • Agent One API
  • CAG Component APIs

Core Technologies of Wolfram Products

  • Wolfram Language
  • Computable Data
  • Wolfram Notebooks
  • Linguistic Understanding

Additional Deployment Options

  • Wolfram Cloud
  • Wolfram Web Engine
  • wolframscript
  • WSTPServer
  • Group & Organizational Licensing
  • All Products
Consulting & Solutions

We deliver solutions for the AI era—combining symbolic computation, data-driven insights and deep technical expertise

Wolfram Consulting

Data Science, Finance & Business

  • Artificial Intelligence
  • Data Science
  • Healthcare
  • Real Estate

Engineering

  • Civil Engineering
  • Automotive Engineering
  • Sustainable Energy

Science & Technology

  • AgTech
  • Biosciences
  • Environmental Science
  • Food Science
  • Quantum Computation
  • Social and Behavioral Sciences

More Wolfram Solutions

Technology for Education

  • Research Universities
  • Colleges & Teaching Universities
  • High Schools
  • Resources for Students

Education Initiatives

  • Next-Gen EdTech
  • Computer-Based Math

More Solutions for Education

  • Contact Us
Learning & Support

Get Started

  • Wolfram Language Introduction
  • Fast Intro for Programmers
  • Fast Intro for Math Students
  • Wolfram Language Documentation

More Learning

  • Highlighted Core Areas
  • Demonstrations
  • YouTube
  • Daily Study Groups
  • Wolfram Schools and Programs
  • Books

Grow Your Skills

  • Wolfram U

    Courses in computing, science, life and more

  • Community

    Learn, solve problems and share ideas.

  • Blog

    News, views and insights from Wolfram

  • Resources for

    Software Developers

Tech Support

  • Contact Us
  • Support FAQs
  • Support FAQs
  • Contact Us
Company
  • About Wolfram
  • Career Center
  • All Sites & Resources
  • Connect & Follow
  • Contact Us

Work with Us

  • Student Ambassador Initiative
  • Wolfram for Startups
  • Student Opportunities
  • Jobs Using Wolfram Language

Educational Programs for Adults

  • Summer School
  • Winter School

Educational Programs for Youth

  • Middle School Camp
  • High School Research Program
  • Computational Adventures

Read

  • Stephen Wolfram's Writings
  • Wolfram Blog
  • Wolfram Tech | Books
  • Wolfram Media
  • Complex Systems

Educational Resources

  • Wolfram MathWorld
  • Wolfram in STEM
  • Wolfram Challenges
  • Wolfram Problem Generator

Wolfram Initiatives

  • Wolfram Science
  • Wolfram Foundation
  • History of Mathematics Project

Events

  • Stephen Wolfram Livestreams
  • Online & In-Person Events
  • Contact Us
  • Connect & Follow
For AIs
  • Your Account
  • User Portal
  • Wolfram Cloud
  • Products
    • Wolfram|One
    • Mathematica
    • System Modeler
    • Compute ServicesUse with Mathematica and Wolfram|One
    • AI AccessUse with Mathematica and Wolfram|One
    • Finance Platform
    • Wolfram|Alpha Notebook Edition
    • Application Server
    • Enterprise Private Cloud
    • Wolfram Engine
    • Wolfram Player
    • Wolfram Cloud App
    • Wolfram Player App

    More mobile apps

    • Wolfram|Alpha
      • Wolfram|Alpha Website
      • Wolfram|Alpha APIs
    • AI Products
      • Wolfram AI Ecosystem
      • Wolfram Foundation Tool
      • Wolfram Cloud MCP
      • Wolfram Local MCP
      • Agent One API
      • CAG Component APIs
    • Core Technologies
      • Wolfram Language
      • Computable Data
      • Wolfram Notebooks
      • Linguistic Understanding
    • Additional Deployment Options
      • Wolfram Cloud
      • Wolfram Web Engine
      • wolframscript
      • WSTPServer
    • Group & Organizational Licensing
    • All Products
  • Consulting & Solutions
    • Wolfram Consulting

    Data Science, Finance & Business

    • Artificial Intelligence
    • Data Science
    • Healthcare
    • Real Estate

    Engineering

    • Civil Engineering
    • Automotive Engineering
    • Sustainable Energy

    Science & Technology

    • AgTech
    • Biosciences
    • Environmental Science
    • Food Science
    • Quantum Computation
    • Social and Behavioral Sciences

    More Wolfram Solutions

    Technology for Education

    • Research Universities
    • Colleges & Teaching Universities
    • High Schools
    • Resources for Students

    Education Initiatives

    • Next-Gen EdTech
    • Computer-Based Math

    More Solutions for Education

    • Contact Us
  • Learning & Support

    Get Started

    • Wolfram Language Introduction
    • Fast Intro for Programmers
    • Fast Intro for Math Students
    • Wolfram Language Documentation

    Grow Your Skills

    • Wolfram U

      Courses in computing, science, life and more

    • Community

      Learn, solve problems and share ideas.

    • Blog

      News, views and insights from Wolfram

    • Resources for

      Software Developers
    • Tech Support
      • Contact Us
      • Support FAQs
    • More Learning
      • Highlighted Core Areas
      • Demonstrations
      • YouTube
      • Daily Study Groups
      • Wolfram Schools and Programs
      • Books
    • Support FAQs
    • Contact Us
  • Company
    • About Wolfram
    • Career Center
    • All Sites & Resources
    • Connect & Follow
    • Contact Us

    Work with Us

    • Student Ambassador Initiative
    • Wolfram for Startups
    • Student Opportunities
    • Jobs Using Wolfram Language

    Educational Programs for Adults

    • Summer School
    • Winter School

    Educational Programs for Youth

    • Middle School Camp
    • High School Research Program
    • Computational Adventures

    Read

    • Stephen Wolfram's Writings
    • Wolfram Blog
    • Wolfram Tech | Books
    • Wolfram Media
    • Complex Systems
    • Educational Resources
      • Wolfram MathWorld
      • Wolfram in STEM
      • Wolfram Challenges
      • Wolfram Problem Generator
    • Wolfram Initiatives
      • Wolfram Science
      • Wolfram Foundation
      • History of Mathematics Project
    • Events
      • Stephen Wolfram Livestreams
      • Online & In-Person Events
    • Contact Us
    • Connect & Follow
  • For AIs
  • Wolfram Cloud
  • Your Account
  • User Portal
Wolfram Language & System Documentation Center
DistributionFitTest
  • See Also
    • EstimatedDistribution
    • FindDistributionParameters
    • HypothesisTestData
    • LocationTest
    • VarianceTest
    • IndependenceTest
    • LogRankTest
    • AndersonDarlingTest
    • KolmogorovSmirnovTest
    • CramerVonMisesTest
    • JarqueBeraALMTest
    • KuiperTest
    • MardiaCombinedTest
    • MardiaKurtosisTest
    • MardiaSkewnessTest
    • BaringhausHenzeTest
    • PearsonChiSquareTest
    • ShapiroWilkTest
    • WatsonUSquareTest
  • Related Guides
    • Probability & Statistics with Quantities
    • Hypothesis Tests
    • Random Variables
    • Probability & Statistics
    • Reliability
    • Statistical Data Analysis
    • Scientific Data Analysis
    • Life Sciences & Medicine: Data & Computation
    • Tabular Modeling
    • See Also
      • EstimatedDistribution
      • FindDistributionParameters
      • HypothesisTestData
      • LocationTest
      • VarianceTest
      • IndependenceTest
      • LogRankTest
      • AndersonDarlingTest
      • KolmogorovSmirnovTest
      • CramerVonMisesTest
      • JarqueBeraALMTest
      • KuiperTest
      • MardiaCombinedTest
      • MardiaKurtosisTest
      • MardiaSkewnessTest
      • BaringhausHenzeTest
      • PearsonChiSquareTest
      • ShapiroWilkTest
      • WatsonUSquareTest
    • Related Guides
      • Probability & Statistics with Quantities
      • Hypothesis Tests
      • Random Variables
      • Probability & Statistics
      • Reliability
      • Statistical Data Analysis
      • Scientific Data Analysis
      • Life Sciences & Medicine: Data & Computation
      • Tabular Modeling

DistributionFitTest[data]

tests whether data is normally distributed.

DistributionFitTest[data,dist]

tests whether data is distributed according to dist.

DistributionFitTest[data,dist,"property"]

returns the value of "property".

Details and Options
Details and Options Details and Options
Examples  
Basic Examples  
Scope  
Testing  
Data Properties  
Reporting  
Options  
Method  
SignificanceLevel  
Applications  
Properties & Relations  
Possible Issues  
Neat Examples  
See Also
Related Guides
History
Cite this Page
BUILT-IN SYMBOL
  • See Also
    • EstimatedDistribution
    • FindDistributionParameters
    • HypothesisTestData
    • LocationTest
    • VarianceTest
    • IndependenceTest
    • LogRankTest
    • AndersonDarlingTest
    • KolmogorovSmirnovTest
    • CramerVonMisesTest
    • JarqueBeraALMTest
    • KuiperTest
    • MardiaCombinedTest
    • MardiaKurtosisTest
    • MardiaSkewnessTest
    • BaringhausHenzeTest
    • PearsonChiSquareTest
    • ShapiroWilkTest
    • WatsonUSquareTest
  • Related Guides
    • Probability & Statistics with Quantities
    • Hypothesis Tests
    • Random Variables
    • Probability & Statistics
    • Reliability
    • Statistical Data Analysis
    • Scientific Data Analysis
    • Life Sciences & Medicine: Data & Computation
    • Tabular Modeling
    • See Also
      • EstimatedDistribution
      • FindDistributionParameters
      • HypothesisTestData
      • LocationTest
      • VarianceTest
      • IndependenceTest
      • LogRankTest
      • AndersonDarlingTest
      • KolmogorovSmirnovTest
      • CramerVonMisesTest
      • JarqueBeraALMTest
      • KuiperTest
      • MardiaCombinedTest
      • MardiaKurtosisTest
      • MardiaSkewnessTest
      • BaringhausHenzeTest
      • PearsonChiSquareTest
      • ShapiroWilkTest
      • WatsonUSquareTest
    • Related Guides
      • Probability & Statistics with Quantities
      • Hypothesis Tests
      • Random Variables
      • Probability & Statistics
      • Reliability
      • Statistical Data Analysis
      • Scientific Data Analysis
      • Life Sciences & Medicine: Data & Computation
      • Tabular Modeling

DistributionFitTest

DistributionFitTest[data]

tests whether data is normally distributed.

DistributionFitTest[data,dist]

tests whether data is distributed according to dist.

DistributionFitTest[data,dist,"property"]

returns the value of "property".

Details and Options

  • DistributionFitTest performs a goodness-of-fit hypothesis test with null hypothesis that data was drawn from a population with distribution dist and alternative hypothesis that it was not.
  • By default, a probability value or -value is returned.
  • A small -value suggests that it is unlikely that the data came from dist.
  • The dist can be any symbolic distribution with numeric and symbolic parameters or a dataset.
  • The data can be univariate {x1,x2,…} or multivariate {{x1,y1,…},{x2,y2,…},…}.
  • DistributionFitTest[data,dist,Automatic] will choose the most powerful test that applies to data and dist for a general alternative hypothesis.
  • DistributionFitTest[data,dist,All] will choose all tests that apply to data and dist.
  • DistributionFitTest[data,dist,"test"] reports the -value according to "test".
  • Many of the tests use the CDF of the test distribution dist and the empirical CDF of the data as well as their difference and =Expectation[d(x),…]. The CDFs and should be the same under the null hypothesis .
  • The following tests can be used for univariate or multivariate distributions:
  • "AndersonDarling"distribution, databased on Expectation[]
    "CramerVonMises"distribution, databased on Expectation[d(x)2]
    "JarqueBeraALM"normalitybased on skewness and kurtosis
    "KolmogorovSmirnov"distribution, databased on sup_x TemplateBox[{{d, (, x, )}}, Abs]
    "Kuiper"distribution, databased on
    "PearsonChiSquare"distribution, databased on expected and observed histogram
    "ShapiroWilk"normalitybased on quantiles
    "WatsonUSquare"distribution, databased on Expectation[]
  • The following tests can be used for multivariate distributions:
  • "BaringhausHenze"normalitybased on empirical characteristic function
    "DistanceToBoundary"uniformitybased on distance to uniform boundaries
    "MardiaCombined"normalitycombined Mardia skewness and kurtosis
    "MardiaKurtosis"normalitybased on multivariate kurtosis
    "MardiaSkewness"normalitybased on multivariate skewness
    "SzekelyEnergy"databased on Newton's potential energy
  • DistributionFitTest[data,dist,"property"] can be used to directly give the value of "property".
  • Properties related to the reporting of test results include:
  • "AllTests"list of all applicable tests
    "AutomaticTest"test chosen if Automatic is used
    "DegreesOfFreedom"the degrees of freedom used in a test
    "PValue"list of -values
    "PValueTable"formatted table of -values
    "ShortTestConclusion"a short description of the conclusion of a test
    "TestConclusion"a description of the conclusion of a test
    "TestData"list of pairs of test statistics and -values
    "TestDataTable"formatted table of -values and test statistics
    "TestStatistic"list of test statistics
    "TestStatisticTable"formatted table of test statistics
    "HypothesisTestData"returns a HypothesisTestData object
  • DistributionFitTest[data,dist,"HypothesisTestData"] returns a HypothesisTestData object htd that can be used to extract additional test results and properties using the form htd["property"].
  • Properties related to the data distribution include:
  • "FittedDistribution"fitted distribution of data
    "FittedDistributionParameters"distribution parameters of data
  • The following options can be given:
  • Method Automaticthe method to use for computing -values
    SignificanceLevel 0.05cutoff for diagnostics and reporting
  • For a test for goodness of fit, a cutoff is chosen such that is rejected only if . The value of used for the "TestConclusion" and "ShortTestConclusion" properties is controlled by the SignificanceLevel option. By default, is set to 0.05.
  • With the setting Method->"MonteCarlo", datasets of the same length as the input si are generated under using the fitted distribution. The EmpiricalDistribution from DistributionFitTest[si,dist,{"TestStatistic",test}] is then used to estimate the -value.

Examples

open all close all

Basic Examples  (3)

Test some data for normality:

Wolfram Language code: data = RandomVariate[NormalDistribution[], 2500];
Wolfram Language code: DistributionFitTest[data]

Create a HypothesisTestData object for further property extraction:

Wolfram Language code: ℋ = DistributionFitTest[data, Automatic, "HypothesisTestData"];

The full test table:

Wolfram Language code: ℋ["TestDataTable", All]

Compare the histogram of the data to the PDF of the test distribution:

Wolfram Language code: Show[Histogram[data, Automatic, "ProbabilityDensity"], Plot[PDF[ℋ["FittedDistribution"], x], {x, -5, 5}, PlotStyle -> Thick]]

Test the fit of a set of data to a particular distribution:

Wolfram Language code: data = RandomVariate[𝒹 = ParetoDistribution[1, 2], 100];

Extract the Anderson–Darling test table:

Wolfram Language code: DistributionFitTest[data, 𝒹, {"TestDataTable", "AndersonDarling"}]

Verify the test results with ProbabilityPlot:

Wolfram Language code: ProbabilityPlot[data, 𝒹]

Test data for goodness of fit to a multivariate distribution:

Wolfram Language code: data = RandomVariate[𝒟 = BinormalDistribution[.5], 100];
Wolfram Language code: ℋ = DistributionFitTest[data, 𝒟, "HypothesisTestData"];
Wolfram Language code: ℋ["TestDataTable", "KolmogorovSmirnov"]

Plot the marginal PDFs of the test distribution against the data to confirm the test results:

Wolfram Language code: Table[Show[SmoothHistogram[data[[All, i]], PlotStyle -> {Orange, Dashed}, PlotRange -> {0, .4}], Plot[PDF[MarginalDistribution[𝒟, i], x], {x, -4, 4}]], {i, 2}]

Scope  (22)

Testing  (16)

Test some data for normality:

Wolfram Language code: data1 = RandomVariate[NormalDistribution[], 500]; data2 = RandomVariate[StudentTDistribution[5], 500];

The -values for the normally distributed data are typically large:

Wolfram Language code: DistributionFitTest[data1]

The -values for data that is not normally distributed are typically small:

Wolfram Language code: DistributionFitTest[data2]

Set the third argument to Automatic to apply a generally powerful and appropriate test:

Wolfram Language code: data = RandomVariate[NormalDistribution[], 10^4];
Wolfram Language code: DistributionFitTest[data]

The property "AutomaticTest" can be used to determine which test was chosen:

Wolfram Language code: DistributionFitTest[data, Automatic, "AutomaticTest"]

Test whether data fits a particular distribution:

Wolfram Language code: data = RandomVariate[WeibullDistribution[1, 2], 10^3];
Wolfram Language code: DistributionFitTest[data, WeibullDistribution[1, 2]]

There is insufficient evidence to reject a good fit to a WeibullDistribution[1,2]:

Wolfram Language code: Show[Histogram[data, Automatic, "ProbabilityDensity"], Plot[PDF[WeibullDistribution[1, 2], x], {x, 0, 12}, PlotStyle -> Thick]]

Test for goodness of fit to a derived distribution:

Wolfram Language code: 𝒟 = MixtureDistribution[{1 / 2, 1 / 2}, {NormalDistribution[-1, 2], ExponentialDistribution[1]}];
Wolfram Language code: data1 = RandomVariate[𝒟, 10^4]; data2 = RandomVariate[NormalDistribution[], 10^4];
Wolfram Language code: Show[Histogram[data1, Automatic, "PDF"], Plot[PDF[𝒟, x], {x, -5, 5}, PlotRange -> All, Axes -> {True, False}, PlotStyle -> Thick]]

The -value is large for the mixture data compared to data not drawn from the mixture:

Wolfram Language code: DistributionFitTest[data1, 𝒟]
Wolfram Language code: DistributionFitTest[data2, 𝒟]

Test for goodness of fit for quantity data:

Wolfram Language code: data = QuantityArray[RandomVariate[NormalDistribution[100, 6], 100], "Centimeters"]

Check for normality:

Wolfram Language code: DistributionFitTest[data, NormalDistribution[μ, σ]]

Check goodness-of-fit for a specific distribution:

Wolfram Language code: DistributionFitTest[data, NormalDistribution[Quantity[1, "Meters"], Quantity[6, "Centimeters"]]]

Test for goodness of fit to a formula-based distribution:

Wolfram Language code: 𝒟 = ProbabilityDistribution[Piecewise[{{x ^ 2 / 9, 0 < x ≤ 3}}], {x, -Infinity, Infinity}];
Wolfram Language code: data = BlockRandom[SeedRandom[2];RandomVariate[𝒟, 50]];
Wolfram Language code: Show[SmoothHistogram[data, PlotStyle -> Dotted], Plot[PDF[𝒟, x], {x, -5, 5}, PlotRange -> All, Axes -> {True, False}, PlotStyle -> {Orange, Thick}]]
Wolfram Language code: DistributionFitTest[data, 𝒟]

Unspecified parameters will be estimated from the data:

Wolfram Language code: data = RandomVariate[NormalDistribution[1, 2], 10^3];

The -value is dependent on which parameters were estimated:

Wolfram Language code: Table[DistributionFitTest[data, NormalDistribution@@i], {i, {{1, 2}, {1, σ}, {μ, 2}, {μ, σ}}}]

Test some data for multivariate normality:

Wolfram Language code: data1 = RandomVariate[BinormalDistribution[.5], 10^3]; data2 = RandomVariate[MultivariateTDistribution[IdentityMatrix[2], 15], 10^3];

The -values for normally distributed data are typically large compared to non-normal data:

Wolfram Language code: Table[DistributionFitTest[data], {data, {data1, data2}}]

Test some data for goodness of fit to a particular multivariate distribution:

Wolfram Language code: data = RandomVariate[UniformDistribution[{{0, 1}, {0, 1}}], 10^3];

Test a MultinormalDistribution and multivariate UniformDistribution, respectively:

Wolfram Language code: Table[DistributionFitTest[data, 𝒟], {𝒟, {Automatic, UniformDistribution[{{0, 1}, {0, 1}}]}}]

Compare the distributions of two datasets:

Wolfram Language code: data1 = RandomVariate[NormalDistribution[], 10^3]; data2 = RandomVariate[NormalDistribution[], 10^3];
Wolfram Language code: DistributionFitTest[data1, data2]

The sample sizes need not be equal:

Wolfram Language code: data3 = RandomVariate[NormalDistribution[], 10^2];
Wolfram Language code: DistributionFitTest[data1, data3]

Compare the distributions of two multivariate datasets:

Wolfram Language code: data1 = RandomVariate[BinormalDistribution[-.99], 10^2]; data2 = RandomVariate[BinormalDistribution[-.99], 10^2]; data3 = RandomVariate[BinormalDistribution[.99], 10^2];

The -values for equally distributed data are large compared to unequally distributed data:

Wolfram Language code: DistributionFitTest[data1, data2]
Wolfram Language code: DistributionFitTest[data1, data3]

Perform a particular goodness-of-fit test:

Wolfram Language code: data = RandomVariate[NormalDistribution[], 10^4];
Wolfram Language code: DistributionFitTest[data, Automatic, "AndersonDarling"]

Any number of tests can be performed simultaneously:

Wolfram Language code: DistributionFitTest[data, Automatic, {"AndersonDarling", "KolmogorovSmirnov"}]

Perform all tests, appropriate to the data and distribution, simultaneously:

Wolfram Language code: data = RandomVariate[NormalDistribution[], 10^4];
Wolfram Language code: DistributionFitTest[data, Automatic, All]

Use the property "AllTests" to identify which tests were used:

Wolfram Language code: DistributionFitTest[data, Automatic, "AllTests"]

Create a HypothesisTestData object for repeated property extraction:

Wolfram Language code: data = RandomVariate[NormalDistribution[], 10^4];
Wolfram Language code: ℋ = DistributionFitTest[data, Automatic, "HypothesisTestData"];

The properties available for extraction:

Wolfram Language code: ℋ["Properties"]

Extract some properties from a HypothesisTestData object:

Wolfram Language code: data = RandomVariate[NormalDistribution[], 10^4];
Wolfram Language code: ℋ = DistributionFitTest[data, NormalDistribution[], "HypothesisTestData"];

The -value and test statistic from a Cramér–von Mises test:

Wolfram Language code: ℋ["PValue", "CramerVonMises"]
Wolfram Language code: ℋ["TestStatistic", "CramerVonMises"]

Extract any number of properties simultaneously:

Wolfram Language code: data = RandomVariate[NormalDistribution[], 100];
Wolfram Language code: ℋ = DistributionFitTest[data, Automatic, "HypothesisTestData"];

The results from the Anderson–Darling -value and test statistic:

Wolfram Language code: ℋ[{{"PValue", "AndersonDarling"}, {"TestStatistic", "AndersonDarling"}}]

Data Properties  (2)

Obtain the fitted distribution when parameters have been unspecified:

Wolfram Language code: data = RandomVariate[NormalDistribution[], 10^4];
Wolfram Language code: ℋ = DistributionFitTest[data, NormalDistribution[μ, σ], "HypothesisTestData"];

Extract the parameters from the fitted distribution:

Wolfram Language code: ℋ["FittedDistributionParameters"]

Plot the PDF of the fitted distribution against the data:

Wolfram Language code: 𝒟 = ℋ["FittedDistribution"]
Wolfram Language code: Show[Plot[PDF[𝒟, x], {x, -4, 4}], SmoothHistogram[data, PlotStyle -> {Dotted, Orange}]]

Confirm the fit with a goodness-of-fit test:

Wolfram Language code: ℋ["KolmogorovSmirnov"]

The test distribution is returned when the parameters have been specified:

Wolfram Language code: data = RandomVariate[NormalDistribution[], 10^4];
Wolfram Language code: 𝒟 = DistributionFitTest[data, NormalDistribution[0, 1], "FittedDistribution"]

Visually compare the data to the fitted distribution:

Wolfram Language code: Show[Histogram[data, Automatic, "ProbabilityDensity"], Plot[PDF[𝒟, x], {x, -4, 4}, PlotStyle -> Thick]]

Reporting  (4)

Tabulate the results from a selection of tests:

Wolfram Language code: data = RandomVariate[NormalDistribution[], 10^3];
Wolfram Language code: ℋ = DistributionFitTest[data, Automatic, "HypothesisTestData"];
Wolfram Language code: ℋ["TestDataTable"]

A full table of all appropriate test results:

Wolfram Language code: ℋ["TestDataTable", All]

A table of selected test results:

Wolfram Language code: ℋ["TestDataTable", {"AndersonDarling", "PearsonChiSquare"}]

Retrieve the entries from a test table for customized reporting:

Wolfram Language code: data = BlockRandom[SeedRandom[1];RandomVariate[NormalDistribution[], 10^3]];
Wolfram Language code: ℋ = DistributionFitTest[data, Automatic, "HypothesisTestData"];
Wolfram Language code: res = ℋ["TestData", All];

The -values are above 0.05, so there is not enough evidence to reject normality at that level:

Wolfram Language code: Show[BarChart[res[[All, 2]], ChartLabels -> Placed[ℋ["AllTests"], Center], BarOrigin -> Left], Graphics[Line[{{.05, 0}, {.05, 11.5}}]]]

Tabulate -values for a test or group of tests:

Wolfram Language code: data = RandomVariate[NormalDistribution[], 10^4];
Wolfram Language code: ℋ = DistributionFitTest[data, Automatic, "HypothesisTestData"];
Wolfram Language code: ℋ["PValueTable", "CramerVonMises"]

The -value from the table:

Wolfram Language code: ℋ["PValue", "CramerVonMises"]

A table of -values from all appropriate tests:

Wolfram Language code: ℋ["PValueTable", All]

A table of -values from a subset of tests:

Wolfram Language code: ℋ["PValueTable", {"AndersonDarling", "CramerVonMises", "WatsonUSquare"}]

Report the test statistic from a test or group of tests:

Wolfram Language code: data = RandomVariate[CauchyDistribution[1, 2], 10^3];
Wolfram Language code: ℋ = DistributionFitTest[data, CauchyDistribution[1, 2], "HypothesisTestData"];
Wolfram Language code: ℋ["TestStatisticTable"]

The test statistic from the table:

Wolfram Language code: ℋ["TestStatistic"]

A table of test statistics from all appropriate tests:

Wolfram Language code: ℋ["TestStatisticTable", All]

Options  (6)

Method  (4)

Use Monte Carlo-based methods, or choose the fastest method automatically:

Wolfram Language code: data = RandomVariate[NormalDistribution[], 100];
Wolfram Language code: DistributionFitTest[data, NormalDistribution[], "CramerVonMises", Method -> "MonteCarlo"]
Wolfram Language code: DistributionFitTest[data, NormalDistribution[], "CramerVonMises", Method -> Automatic]

Set the number of samples to use for Monte Carlo-based methods:

Wolfram Language code: data = RandomVariate[NormalDistribution[], 100];
Wolfram Language code: pts = Table[{i, DistributionFitTest[data, NormalDistribution[], "CramerVonMises", Method -> {"MonteCarlo", "MonteCarloSamples" -> i}]}, {i, Range[5, 1000, 50]}];

The Monte Carlo estimate converges to the true -value with increasing samples:

Wolfram Language code: pval = DistributionFitTest[data, NormalDistribution[], "CramerVonMises"];
Wolfram Language code: Show[ListLinePlot[pts, PlotRange -> {0, 1}, FrameLabel -> {"Samples", "P-Value"}, Frame -> True, AxesOrigin -> {0, 0}], Graphics[{Dashed, Line[{{0, pval}, {1000, pval}}]}]]

Set the random seed used in Monte Carlo-based methods:

Wolfram Language code: data = RandomVariate[NormalDistribution[], 100];
Wolfram Language code: pts = Table[{i, DistributionFitTest[data, NormalDistribution[], "CramerVonMises", Method -> {"MonteCarlo", "RandomSeed" -> i}]}, {i, Range[1, 10]}];

The seed affects the state of the generator and has some effect on the resulting -value:

Wolfram Language code: pval = DistributionFitTest[data, NormalDistribution[], "CramerVonMises"];
Wolfram Language code: Show[ListLinePlot[pts, PlotRange -> {Min[pts[[All, 2]]], Max[pts[[All, 2]]]}, FrameLabel -> {"Seed", "P-Value"}, Frame -> True, AxesOrigin -> {0, 0}], Graphics[{Dashed, Line[{{0, pval}, {100, pval}}]}]]

Monte Carlo simulations generate many test statistics under :

Wolfram Language code: mcSamp = 250;seed = 9;n = 50;𝒟 = NormalDistribution[μ, σ];
Wolfram Language code: data = RandomVariate[NormalDistribution[1, 2], n];
Wolfram Language code: ℋ = DistributionFitTest[data, 𝒟, "HypothesisTestData", Method -> {"MonteCarlo", "MonteCarloSamples" -> mcSamp, "RandomSeed" -> seed}];
Wolfram Language code: simDat = BlockRandom[SeedRandom[seed];RandomVariate[ℋ["FittedDistribution"], {mcSamp, n}]];
Wolfram Language code: testDist = DistributionFitTest[#, 𝒟, "TestStatistic"]& /@ simDat;

The estimated distribution of the test statistics under :

Wolfram Language code: SmoothHistogram[testDist, Filling -> Axis]

The empirical estimate of the -value agrees with the Monte Carlo estimate:

Wolfram Language code: Probability[t > ℋ["TestStatistic"], tEmpiricalDistribution[testDist]]
Wolfram Language code: ℋ["PValue"]

SignificanceLevel  (2)

By default, a significance level of 0.05 is used:

Wolfram Language code: data = BlockRandom[SeedRandom[234];RandomVariate[NormalDistribution[0, 1], 100]];
Wolfram Language code: DistributionFitTest[data, Automatic, "TestConclusion"]//TraditionalForm

Set the significance level to 0.001:

Wolfram Language code: DistributionFitTest[data, Automatic, "TestConclusion", SignificanceLevel -> 0.001]//TraditionalForm

The significance level is also used for "ShortTestConclusion":

Wolfram Language code: data = BlockRandom[SeedRandom[234];RandomVariate[NormalDistribution[0, 1], 100]];
Wolfram Language code: ℋ1 = DistributionFitTest[data, Automatic, "HypothesisTestData", SignificanceLevel -> .05];
Wolfram Language code: ℋ2 = DistributionFitTest[data, Automatic, "HypothesisTestData", SignificanceLevel -> .001];
Wolfram Language code: ℋ1["ShortTestConclusion"]
Wolfram Language code: ℋ2["ShortTestConclusion"]

Applications  (12)

Analyze whether a dataset is drawn from a normal distribution:

Wolfram Language code: data = {87, 91, 97 , 80, 71, 86, 72, 93, 83, 73, 76}; 𝒹 = NormalDistribution[82, 9];

Perform a series of goodness-of-fit tests:

Wolfram Language code: ℋ = DistributionFitTest[data, 𝒹, "HypothesisTestData"];
Wolfram Language code: ℋ["TestDataTable"]

Visually compare the empirical and theoretical CDFs in a QuantilePlot:

Wolfram Language code: QuantilePlot[data, 𝒹]

Visually compare the empirical CDF to that of the test distribution:

Wolfram Language code: Plot[{CDF[ℋ["FittedDistribution"], x], CDF[EmpiricalDistribution[data], x]}//Evaluate, {x, 50, 110}, Exclusions -> None, Filling -> {1 -> {2}}, Frame -> True]

Determine whether snowfall accumulations in Buffalo are normally distributed:

Wolfram Language code: snow = ExampleData[{"Statistics", "BuffaloSnow"}];
Wolfram Language code: ℋ = DistributionFitTest[snow, Automatic, "HypothesisTestData"];

Use the Jarque–Bera ALM test and Shapiro–Wilk test to assess normality:

Wolfram Language code: ℋ["TestDataTable", {"JarqueBeraALM", "ShapiroWilk"}]

The SmoothHistogram agrees with the test results:

Wolfram Language code: Show[SmoothHistogram[snow, PlotStyle -> {Dotted, Orange}], Plot[PDF[ℋ["FittedDistribution"], x], {x, 0, 150}]]

The QuantilePlot suggests a reasonably good fit:

Wolfram Language code: QuantilePlot[snow, ℋ["FittedDistribution"]]

Use a goodness-of-fit test to verify the fit suggested by visualization such as a histogram:

Wolfram Language code: 𝒹 = BetaDistribution[2, 2]; BlockRandom[SeedRandom[1];data = RandomVariate[𝒹, 10000]];
Wolfram Language code: Show[Histogram[data, Automatic, "ProbabilityDensity"], Plot[PDF[𝒹, x], {x, 0, 1}, PlotStyle -> Thick]]

The Kolmogorov–Smirnov test agrees with the good fit suggested in the histogram:

Wolfram Language code: DistributionFitTest[data, 𝒹, "KolmogorovSmirnov"]

Test whether the absolute magnitudes of the 100 brightest stars are normally distributed:

Wolfram Language code: data = EntityClass["Star", "StarBrightest100"]["AbsoluteMagnitude"];
Wolfram Language code: ℋ = DistributionFitTest[data, NormalDistribution[a, b], "HypothesisTestData"];

The value of the statistic and p-value for the automatic test:

Wolfram Language code: ℋ["TestDataTable", Automatic]

Visually check the result:

Wolfram Language code: Show[SmoothHistogram[data, PlotStyle -> {Dotted, Orange}, PlotRange -> {0, .15}], Plot[PDF[ℋ["FittedDistribution"], x], {x, -15, 10}]]

Test whether multivariate data is uniformly distributed over a box:

Wolfram Language code: ExampleData[{"Statistics", "UgandaVolcanoes"}, "LongDescription"]
Wolfram Language code: data = ExampleData[{"Statistics", "UgandaVolcanoes"}];
Wolfram Language code: box1 = {{320, 2760}, {970, 4150}}; box2 = {{1100, 1800}, {1600, 3000}};
Wolfram Language code: Show[ListPlot[data, PlotRange -> {{200, 2800}, {500, 5000}}], Graphics[{EdgeForm[Orange], Opacity[0], Rectangle@@Transpose[box1]}], Graphics[{EdgeForm[Gray], Opacity[0], Rectangle@@Transpose[box2]}], AspectRatio -> 1, ImageSize -> Medium]

Use the distance-to-boundary test:

Wolfram Language code: DistributionFitTest[data, UniformDistribution[box1], {"TestDataTable", "DistanceToBoundary"}]
Wolfram Language code: DistributionFitTest[Pick[data, (Boole[1100 ≤ #1[[1]] ≤ 1800 && 1600 ≤ #1[[2]] ≤ 3000]&) /@ data, 1], UniformDistribution[box2], {"TestDataTable", "DistanceToBoundary"}]

Use Szekely's energy test to compare two multivariate datasets:

Wolfram Language code: ExampleData[{"Statistics", "SwissBankNotes"}, "ColumnDescriptions"]
Wolfram Language code: data = ExampleData[{"Statistics", "SwissBankNotes"}];
Wolfram Language code: counterfeit = Pick[data[[All, 1 ;; 6]], data[[All, -1]], 1]; genuine = Pick[data[[All, 1 ;; 6]], data[[All, -1]], 0];

The distributions for measures of counterfeit and genuine notes are significantly different:

Wolfram Language code: DistributionFitTest[counterfeit, genuine, {"TestDataTable", "SzekelyEnergy"}]

Visually compare the marginal distributions to determine the origin of the discrepancy:

Wolfram Language code: Table[SmoothHistogram[{counterfeit[[All, i]], genuine[[All, i]]}, PlotLabel -> Row[{"Measure:", i}]], {i, 6}]

Test whether data is uniformly distributed on a unit circle:

Wolfram Language code: Subscript[rad, 1] = {1.77, 3.63, 5.21, 5.54, 0.17, 6.26, 2.84, 2.1, 5.73, 5.13, 2.30, 4.13, 3.56, 0.6, 0.99};
Wolfram Language code: Subscript[rad, 2] = {0.96, 0.83, 1.18, 0.97, 1.92, 1.99, 0.94, 0.89, 0.98, 1.33, 0.86, 0.58, 0.73, 1.85, 2.3};

Kuiper's test and the Watson test are useful for testing uniformity on a circle:

Wolfram Language code: Table[DistributionFitTest[i, UniformDistribution[{0, 2 Pi}], {"TestDataTable", {"Kuiper", "WatsonUSquare"}}], {i, {Subscript[rad, 1], Subscript[rad, 2]}}]

The first dataset is randomly distributed, the second is clustered:

Wolfram Language code: Table[Show[Graphics[{StandardGray, Circle[]}], ListPlot[{Cos[#], Sin[#]}& /@ i, PlotStyle -> PointSize[.05]]], {i, {Subscript[rad, 1], Subscript[rad, 2]}}]

Determine if a model is appropriate for day-to-day point changes in the S&P 500 index:

Wolfram Language code: sp500 = FinancialData["SP500", All]; data = Log[Ratios[sp500]]

The histogram suggests a heavy-tailed, symmetric distribution:

Wolfram Language code: Histogram[data, PlotRange -> {{-.05, .05}, All}]

Try a LaplaceDistribution:

Wolfram Language code: ℋ = DistributionFitTest[data, LaplaceDistribution[a, b], "HypothesisTestData"];
Wolfram Language code: ℋ["TestDataTable", All]

For very large datasets, small deviations from the test distribution are readily detected:

Wolfram Language code: Show[SmoothHistogram[data, PlotStyle -> Orange, PlotRange -> {0, 2}], Plot[PDF[ℋ["FittedDistribution"], x], {x, Min[data], Max[data]}]]

Test the residuals from a LinearModelFit for normality:

Wolfram Language code: data = ExampleData[{"Statistics", "OldFaithful"}];
Wolfram Language code: lm = LinearModelFit[data, x, x];
Wolfram Language code: ℋ = DistributionFitTest[res = lm["FitResiduals"], Automatic, "HypothesisTestData"];

The Shapiro–Wilk test suggests that the residuals are not normally distributed:

Wolfram Language code: ℋ["TestDataTable", "ShapiroWilk"]

The QuantilePlot suggests large deviations in the left tail of the distribution:

Wolfram Language code: QuantilePlot[res, ℋ["FittedDistribution"]]

Simulate the distribution of a test statistic to obtain a Monte Carlo -value:

Wolfram Language code: mcSamples = RandomVariate[𝒹 = NormalDistribution[], {2500, 25}];
Wolfram Language code: Subscript[ℋ, MC] = DistributionFitTest[#, 𝒹, "HypothesisTestData"]& /@ mcSamples;
Wolfram Language code: T = Table[i["TestStatistic", "AndersonDarling"], {i, Subscript[ℋ, MC]}];

Visualize the distribution of the test statistic using SmoothHistogram:

Wolfram Language code: SmoothHistogram[T, PlotLabel -> "A-D Distribution: n = 25", Filling -> Axis]

Obtain the Monte Carlo -value from an Anderson–Darling test:

Wolfram Language code: data = RandomReal[𝒹, 25];
Wolfram Language code: ℋ = DistributionFitTest[data, 𝒹, "HypothesisTestData"];
Wolfram Language code: t = ℋ["TestStatistic", "AndersonDarling"]
Wolfram Language code: Subscript[P, MC] = Length[Cases[T, x_ /; x > t]] / Length[T]//N

Compare with the -value returned by DistributionFitTest:

Wolfram Language code: ℋ["PValue", "AndersonDarling"] - Subscript[P, MC]

Obtain an estimate of the power for a hypothesis test:

Wolfram Language code: data = Table[RandomVariate[StudentTDistribution[2], {500, i}], {i, n = {5, 7, 10, 15, 20, 25, 30, 40, 50}}];
Wolfram Language code: ℋ = Table[DistributionFitTest[data[[i, j]], NormalDistribution[], "ShapiroWilk"], {i, Length[data]}, {j, Length[data[[i]]]}];
Wolfram Language code: pC = Interpolation[Transpose[{n, Table[Probability[x ≤ 0.05, xi], {i, ℋ}]}], InterpolationOrder -> 1];

Visualize the approximate power curve:

Wolfram Language code: Plot[pC[x], {x, 5, 50}, PlotRange -> {0, 1}, Ticks -> {n, Automatic}, AxesOrigin -> {0, 0}]

Estimate the power of the Shapiro–Wilk test when the underlying distribution is a StudentTDistribution[2], the test size is 0.05, and the sample size is 35:

Wolfram Language code: pC[35]//N

Smoothing a dataset using kernel density estimation can remove noise while preserving the structure of the underlying distribution of the data. Here two datasets are created from the same distribution:

Wolfram Language code: data1 = BlockRandom[SeedRandom[1];RandomVariate[NormalDistribution[], 100]]; data2 = BlockRandom[SeedRandom[14];RandomVariate[NormalDistribution[], 100]];

The unsmoothed data provides a noisy estimate of the underlying distributions:

Wolfram Language code: Plot[Evaluate[CDF[EmpiricalDistribution[#], x]& /@ {data1, data2}], {x, -5, 5}, Exclusions -> None]

Noise would lead to committing a type I error:

Wolfram Language code: DistributionFitTest[data1, data2]
Wolfram Language code: 𝒟 = SmoothKernelDistribution[data2];
Wolfram Language code: Plot[{CDF[EmpiricalDistribution[data1], x], CDF[𝒟, x]}, {x, -5, 5}, Exclusions -> None]

Smoothing reduces the noise and results in a correct conclusion at the 5% level:

Wolfram Language code: DistributionFitTest[data1, 𝒟]

Properties & Relations  (16)

By default, univariate data is compared to a NormalDistribution:

Wolfram Language code: data = RandomVariate[CauchyDistribution[0, 1], 10];
Wolfram Language code: ℋ1 = DistributionFitTest[data, Automatic, "HypothesisTestData"]; ℋ2 = DistributionFitTest[data, NormalDistribution[μ, σ], "HypothesisTestData"];

The parameters of the distribution are estimated from the data:

Wolfram Language code: {ℋ1["FittedDistribution"], ℋ2["FittedDistribution"]}

Multivariate data is compared to a MultinormalDistribution by default:

Wolfram Language code: data = RandomVariate[BinormalDistribution[.5], 10];
Wolfram Language code: ℋ1 = DistributionFitTest[data, Automatic, "HypothesisTestData"]; ℋ2 = DistributionFitTest[data, MultinormalDistribution[{μ1, μ2}, IdentityMatrix[2]], "HypothesisTestData"];

Unspecified parameters of the distribution are estimated from the data:

Wolfram Language code: {ℋ1["FittedDistribution"], ℋ2["FittedDistribution"]}//TraditionalForm

Maximum likelihood estimates are used for unspecified parameters of the test distribution:

Wolfram Language code: data = RandomVariate[ExponentialDistribution[3], 10^3];
Wolfram Language code: ℋ = DistributionFitTest[data, ExponentialDistribution[λ], "FittedDistribution"]
Wolfram Language code: EstimatedDistribution[data, ExponentialDistribution[λ]]

The -value suggests the expected proportion of false positives (type I errors):

Wolfram Language code: data = RandomVariate[NormalDistribution[], {1000, 10}];
Wolfram Language code: pvals = Table[DistributionFitTest[i, NormalDistribution[], "CramerVonMises"], {i, data}];

Setting the size of a test to 0.05 results in an erroneous rejection of about 5% of the time:

Wolfram Language code: Probability[x ≤ 0.05, xpvals]//N

Type II errors arise when is not rejected, given it is false:

Wolfram Language code: data = RandomVariate[CauchyDistribution[0, 1], {1000, 25}];
Wolfram Language code: ℋs = Table[DistributionFitTest[i, NormalDistribution[a, b], "AndersonDarling"], {i, data}];

Increasing the size of the test lowers the type II error rate:

Wolfram Language code: ListLinePlot[Table[{sz, Probability[x > sz, xℋs]//N}, {sz, Range[0.001, .25, .01]}], AxesLabel -> {"Size", "Type II Error"}]

The -value for a valid test has a UniformDistribution[{0,1}] under :

Wolfram Language code: data = RandomVariate[NormalDistribution[], {1000, 25}];
Wolfram Language code: tests = {"AndersonDarling", "CramerVonMises", "KolmogorovSmirnov", "Kuiper"};
Wolfram Language code: p = Table[DistributionFitTest[i, NormalDistribution[], tests], {i, data}]//Transpose;
Wolfram Language code: Table[Histogram[p[[i]], Automatic, "ProbabilityDensity", PlotLabel -> tests[[i]]], {i, 4}]

Verify the uniformity using the Kolmogorov–Smirnov test:

Wolfram Language code: TableForm[Table[{tests[[i]], Round[DistributionFitTest[p[[i]], UniformDistribution[{0, 1}], "KolmogorovSmirnov"], .001]}, {i, 4}]]

The power of each test is the probability of rejecting when it is false:

Wolfram Language code: data = RandomVariate[CauchyDistribution[0, 1], {1000, 25}];
Wolfram Language code: tests = {"AndersonDarling", "CramerVonMises", "JarqueBeraALM", "KolmogorovSmirnov", "Kuiper", "PearsonChiSquare", "ShapiroWilk", "WatsonUSquare"};
Wolfram Language code: p = Table[DistributionFitTest[i, Automatic, tests], {i, data}]//Transpose;

Under these conditions, the Pearson test has the lowest power:

Wolfram Language code: N[Table[{tests[[i]], Probability[x ≤ 0.05, xp[[i]]]}, {i, Length[tests]}]]//TableForm

The power of each test decreases with sample size:

Wolfram Language code: data = RandomVariate[CauchyDistribution[0, 1], {500, 10}];
Wolfram Language code: tests = {"AndersonDarling", "CramerVonMises", "JarqueBeraALM", "KolmogorovSmirnov", "Kuiper", "PearsonChiSquare", "ShapiroWilk", "WatsonUSquare"};
Wolfram Language code: p = Table[DistributionFitTest[i, Automatic, tests], {i, data}]//Transpose;

Some tests perform better than others with small sample sizes:

Wolfram Language code: N[Table[{tests[[i]], Probability[x ≤ 0.05, xp[[i]]]}, {i, Length[tests]}]]//TableForm

Some tests are more powerful than others for detecting differences in location:

Wolfram Language code: data = RandomVariate[NormalDistribution[1, 1], {500, 25}];
Wolfram Language code: tests = {"AndersonDarling", "CramerVonMises", "KolmogorovSmirnov", "Kuiper", "PearsonChiSquare", "WatsonUSquare"};
Wolfram Language code: p = Table[DistributionFitTest[i, NormalDistribution[0, σ], tests], {i, data}]//Transpose;

The power of the tests:

Wolfram Language code: N[Table[{tests[[i]], Probability[x ≤ 0.05, xp[[i]]]}, {i, Length[tests]}]]//TableForm

Some tests are more powerful than others for detecting differences in scale:

Wolfram Language code: data = RandomVariate[NormalDistribution[1, 1], {500, 25}];
Wolfram Language code: tests = {"AndersonDarling", "CramerVonMises", "KolmogorovSmirnov", "Kuiper", "PearsonChiSquare", "WatsonUSquare"};
Wolfram Language code: p = Table[DistributionFitTest[i, NormalDistribution[μ, 2], tests], {i, data}]//Transpose;

The power of the tests:

Wolfram Language code: N[Table[{tests[[i]], Probability[x ≤ 0.05, xp[[i]]]}, {i, Length[tests]}]]//TableForm

The Pearson test requires large sample sizes to have high power:

Wolfram Language code: data1 = RandomVariate[StudentTDistribution[2], {500, 25}]; data2 = RandomVariate[StudentTDistribution[2], {500, 50}]; data3 = RandomVariate[StudentTDistribution[2], {500, 100}];
Wolfram Language code: p1 = Table[DistributionFitTest[i, Automatic, "PearsonChiSquare"], {i, data1}]; p2 = Table[DistributionFitTest[i, Automatic, "PearsonChiSquare"], {i, data2}]; p3 = Table[DistributionFitTest[i, Automatic, "PearsonChiSquare"], {i, data3}];

The power of the tests:

Wolfram Language code: {Probability[x ≤ 0.05, xp1], Probability[x ≤ 0.05, xp2], Probability[x ≤ 0.05, xp3]}//N

Some tests perform better than others when testing normality:

Wolfram Language code: data = RandomVariate[StudentTDistribution[2], {500, 100}];
Wolfram Language code: tests = {"AndersonDarling", "CramerVonMises", "JarqueBeraALM", "KolmogorovSmirnov", "Kuiper", "PearsonChiSquare", "ShapiroWilk", "WatsonUSquare"};
Wolfram Language code: p = Table[DistributionFitTest[i, NormalDistribution[a, b], tests], {i, data}]//Transpose;

The Jarque–Bera ALM and Shapiro–Wilk tests are the most powerful for small samples:

Wolfram Language code: N[Table[{tests[[i]], Probability[x ≤ 0.05, xp[[i]]]}, {i, Length[tests]}]]//TableForm

Tests designed for the composite hypothesis of normality ignore specified parameters:

Wolfram Language code: data = RandomVariate[NormalDistribution[], 100];
Wolfram Language code: ℋ1 = DistributionFitTest[data, NormalDistribution[1, 10], "ShapiroWilk"]
Wolfram Language code: ℋ2 = DistributionFitTest[data, NormalDistribution[10, 1], "ShapiroWilk"]

Different tests examine different properties of the distribution. Conclusions based on a particular test may not always agree with those based on another test:

Wolfram Language code: data = RandomVariate[StudentTDistribution[3], {100, 50}];
Wolfram Language code: tests = {"Kuiper", "CramerVonMises", "KolmogorovSmirnov", "PearsonChiSquare"};
Wolfram Language code: pvs = Table[(DistributionFitTest[#1, Automatic, i]&) /@ data, {i, tests}];
Wolfram Language code: α = 0.2;
Wolfram Language code: conclusions[α_] := Show[Graphics[{Opacity[.5], Lighter[Purple], Rectangle[{0, 0}, {α, α}]}], Graphics[{Opacity[.5], Orange, Rectangle[{α, α}, {1, 1}]}], Graphics[{Opacity[.1], Gray, Rectangle[{0, α}, {α, 1}]}], Graphics[{Opacity[.1], Gray, Rectangle[{α, 0}, {1, α}]}]];

The green region represents a correct conclusion by both tests. Points fall in the red region when a type II error is committed by both tests. The gray region shows where the tests disagree:

Wolfram Language code: MapThread[Show[conclusions[α], ListPlot[Transpose[{pvs[[#1]], pvs[[#2]]}], AspectRatio -> 1], Frame -> True, FrameLabel -> {tests[[#1]], tests[[#2]]}]&, {{1, 1, 1, 2, 2, 3}, {2, 3, 4, 3, 4, 4}}]

Estimating parameters prior to testing affects the distribution of the test statistic:

Wolfram Language code: data = RandomVariate[NormalDistribution[], {1000, 35}];
Wolfram Language code: ℋ1 = Table[DistributionFitTest[i, NormalDistribution[μ, σ], "TestData"], {i, data}]//Transpose;

The distribution of the test statistics and resulting -values under :

Wolfram Language code: {Histogram[ℋ1[[1]], Automatic, "PDF", PlotLabel -> "Test Statistics"], Histogram[ℋ1[[2]], Automatic, "PDF", PlotLabel -> "P-Values"]}
Wolfram Language code: ℋ2 = Table[DistributionFitTest[i, EstimatedDistribution[i, NormalDistribution[μ, σ]], "TestData"], {i, data}]//Transpose;

Failing to account for the estimation leads to an overestimate of -values:

Wolfram Language code: {Histogram[ℋ2[[1]], Automatic, "PDF", PlotLabel -> "Test Statistics"], Histogram[ℋ2[[2]], Automatic, "PDF", PlotLabel -> "P-Values"]}

The distribution fit test works with the values only when the input is a TimeSeries:

Wolfram Language code: ts = TemporalData[TimeSeries, {{{1.224578634529677, 0.47929635789978015, 0.6572781300178168, 0.21496048742669355, 0.7299608014554928, -0.2495111111278263, -1.3286551762002712, 0.552725018274874, 0.19272112205837066, 1.1809144012420882, -1.1671 ... 40938613662046, 1.052394590214582, 0.9345044123980388, 0.38537803109557855, -0.48660931166089394, -0.71203560340161}}, {{0, 100, 1}}, 1, {"Continuous", 1}, {"Discrete", 1}, 1, {ValueDimensions -> 1, ResamplingMethod -> None}}, False, 10.1];
Wolfram Language code: DistributionFitTest[ts, Automatic, {"TestDataTable", All}]
Wolfram Language code: DistributionFitTest[ts["Values"], Automatic, {"TestDataTable", All}]
Wolfram Language code: %% == %

Possible Issues  (5)

Some tests require that the parameters be prespecified and not estimated for valid -values:

Wolfram Language code: data = RandomVariate[ArcSinDistribution[{-1, 4}], 10];
Wolfram Language code: ℋ = DistributionFitTest[data, ArcSinDistribution[{a, b}], "AndersonDarling"]

It is usually possible to use Monte Carlo methods to arrive at a valid -value:

Wolfram Language code: DistributionFitTest[data, ArcSinDistribution[{a, b}], "AndersonDarling", Method -> "MonteCarlo"]

For many distributions, corrections are applied when parameters are estimated:

Wolfram Language code: ℋ2 = DistributionFitTest[RandomVariate[NormalDistribution[], 10], NormalDistribution[a, b], "AndersonDarling"]

The Jarque–Bera ALM test must have sample sizes of at least 10 for valid -values:

Wolfram Language code: data = RandomVariate[NormalDistribution[], 5];
Wolfram Language code: DistributionFitTest[data, Automatic, "JarqueBeraALM"]

Use Monte Carlo methods to arrive at a valid -value:

Wolfram Language code: DistributionFitTest[data, Automatic, "JarqueBeraALM", Method -> "MonteCarlo"]

The Kolmogorov–Smirnov test and Kuiper's test expect no ties in the data:

Wolfram Language code: data = {1., 2., 1.5, 2., 1.75, 2.5, 3.};
Wolfram Language code: DistributionFitTest[data, Automatic, {"TestDataTable", {"KolmogorovSmirnov", "Kuiper"}}]

The Jarque–Bera ALM test and Shapiro–Wilk test are only valid for testing normality:

Wolfram Language code: data = RandomVariate[BetaDistribution[1, 2], 10];
Wolfram Language code: DistributionFitTest[data, BetaDistribution[a, b], {"TestDataTable", {"JarqueBeraALM", "ShapiroWilk"}}]

Careful interpretation is required when some tests are used for discrete distributions:

Wolfram Language code: data = RandomVariate[𝒹 = DiscreteUniformDistribution[{1, 10}], 100];
Wolfram Language code: ℋ = DistributionFitTest[data, 𝒹, "HypothesisTestData"];
Wolfram Language code: ℋ["TestDataTable", {"CramerVonMises", "AndersonDarling", "KolmogorovSmirnov", "Kuiper", "WatsonUSquare"}]

The Pearson test applies directly for discrete distributions:

Wolfram Language code: ℋ["TestDataTable", "PearsonChiSquare"]

Neat Examples  (1)

The distributions of some test statistics:

Wolfram Language code: data = RandomVariate[𝒹 = NormalDistribution[], {5000, 50}];
Wolfram Language code: ℋ = DistributionFitTest[#, 𝒹, "HypothesisTestData"]& /@ data;
Wolfram Language code: T = Table[h["TestStatistic", i], {h, ℋ}, {i, tests = {"AndersonDarling", "CramerVonMises", "Kuiper", "KolmogorovSmirnov", "PearsonChiSquare", "WatsonUSquare"}}]//Transpose;
Wolfram Language code: Table[SmoothHistogram[T[[i]], PlotLabel -> tests[[i]], Filling -> Axis], {i, 6}]

See Also

EstimatedDistribution  FindDistributionParameters  HypothesisTestData  LocationTest  VarianceTest  IndependenceTest  LogRankTest  AndersonDarlingTest  KolmogorovSmirnovTest  CramerVonMisesTest  JarqueBeraALMTest  KuiperTest  MardiaCombinedTest  MardiaKurtosisTest  MardiaSkewnessTest  BaringhausHenzeTest  PearsonChiSquareTest  ShapiroWilkTest  WatsonUSquareTest

Related Guides

    ▪
  • Probability & Statistics with Quantities
  • ▪
  • Hypothesis Tests
  • ▪
  • Random Variables
  • ▪
  • Probability & Statistics
  • ▪
  • Reliability
  • ▪
  • Statistical Data Analysis
  • ▪
  • Scientific Data Analysis
  • ▪
  • Life Sciences & Medicine: Data & Computation
  • ▪
  • Tabular Modeling

History

Introduced in 2010 (8.0) | Updated in 2014 (10.0) ▪ 2015 (10.2)

Wolfram Research (2010), DistributionFitTest, Wolfram Language function, https://reference.wolfram.com/language/ref/DistributionFitTest.html (updated 2015).

Text

Wolfram Research (2010), DistributionFitTest, Wolfram Language function, https://reference.wolfram.com/language/ref/DistributionFitTest.html (updated 2015).

CMS

Wolfram Language. 2010. "DistributionFitTest." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/DistributionFitTest.html.

APA

Wolfram Language. (2010). DistributionFitTest. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DistributionFitTest.html

BibTeX

@misc{reference.wolfram_2026_distributionfittest, author="Wolfram Research", title="{DistributionFitTest}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/DistributionFitTest.html}", note=[Accessed: 01-September-2026]}

BibLaTeX

@online{reference.wolfram_2026_distributionfittest, organization={Wolfram Research}, title={DistributionFitTest}, year={2015}, url={https://reference.wolfram.com/language/ref/DistributionFitTest.html}, note=[Accessed: 01-September-2026]}

Top
Introduction for Programmers
Introductory Book
Wolfram Function Repository | Wolfram Data Repository | Wolfram Data Drop | Wolfram Language Products
Top
  • Products
  • Wolfram|One
  • Mathematica
  • AI Access
  • Compute Services
  • System Modeler

  • Wolfram|Alpha Notebook Edition
  • Wolfram|Alpha Pro
  • Mobile Apps

  • Wolfram Engine
  • Wolfram Player

  • Volume & Site Licensing
  • Server Deployment Options
  • Consulting
  • Wolfram Consulting
  • Repositories
  • Data Repository
  • Function Repository
  • Community Paclet Repository
  • Neural Net Repository
  • Prompt Repository

  • Wolfram Language Example Repository
  • Notebook Archive
  • Wolfram GitHub
  • Learning
  • Wolfram U
  • Wolfram Language Documentation
  • Webinars & Training
  • Educational Programs

  • Wolfram Language Introduction
  • Fast Introduction for Programmers
  • Fast Introduction for Math Students
  • Books

  • Wolfram Community
  • Wolfram Blog
  • Public Resources
  • Wolfram|Alpha
  • Wolfram Problem Generator
  • Wolfram Challenges

  • Computer-Based Math
  • Computational Thinking
  • Computational Adventures

  • Demonstrations Project
  • Wolfram Data Drop
  • MathWorld
  • Wolfram Science
  • Wolfram Media Publishing
  • Customer Resources
  • Store
  • Product Downloads
  • User Portal
  • Your Account
  • Organization Access

  • Support FAQ
  • Contact Support
  • Company
  • About Wolfram
  • Careers
  • Contact
  • Events
Wolfram Community Wolfram Blog
Legal & Privacy Policy
WolframAlpha.com | WolframCloud.com
© 2026 Wolfram
© 2026 Wolfram | Legal & Privacy Policy |
English