WatsonUSquareTest[data]
tests whether data is normally distributed using the Watson
test.
WatsonUSquareTest[data,dist]
tests whether data is distributed according to dist using the Watson
test.
WatsonUSquareTest[data,dist,"property"]
returns the value of "property".
WatsonUSquareTest
WatsonUSquareTest[data]
tests whether data is normally distributed using the Watson
test.
WatsonUSquareTest[data,dist]
tests whether data is distributed according to dist using the Watson
test.
WatsonUSquareTest[data,dist,"property"]
returns the value of "property".
Details and Options
- WatsonUSquareTest performs the Watson
goodness-of-fit 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,…},…}.
- The Watson
test assumes that the data came from a continuous distribution. - The Watson
test effectively uses a test statistic based on
where
and
,
is the empirical CDF of data, and
is the CDF of dist. - For multivariate tests, the sum of the univariate marginal
-values is used and is assumed to follow a UniformSumDistribution under
. - WatsonUSquareTest[data,dist,"HypothesisTestData"] returns a HypothesisTestData object htd that can be used to extract additional test results and properties using the form htd["property"].
- WatsonUSquareTest[data,dist,"property"] can be used to directly give the value of "property".
- Properties related to the reporting of test results include:
-
"PValue"
-value"PValueTable" formatted version of "PValue" "ShortTestConclusion" a short description of the conclusion of a test "TestConclusion" a description of the conclusion of a test "TestData" test statistic and
-value"TestDataTable" formatted version of "TestData" "TestStatistic" test statistic "TestStatisticTable" formatted "TestStatistic" - The following properties are independent of which test is being performed.
- Properties related to the data distribution include:
-
"FittedDistribution" fitted distribution of data "FittedDistributionParameters" distribution parameters of data - The following options can be given:
-
Method Automatic the method to use for computing
-valuesSignificanceLevel 0.05 cutoff 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
are generated under
using the fitted distribution. The EmpiricalDistribution from WatsonUSquareTest[si,dist,"TestStatistic"] is then used to estimate the
-value.
Examples
open all close allBasic Examples (4)
Perform a Watson
test for normality:
data = RandomVariate[NormalDistribution[], 10^4];WatsonUSquareTest[data]Test the fit of some data to a particular distribution:
data = RandomVariate[LaplaceDistribution[1, 2], 10^3];WatsonUSquareTest[data, LaplaceDistribution[1, 2]]Compare the distributions of two datasets:
data1 = RandomVariate[NormalDistribution[], 100];data2 = RandomVariate[NormalDistribution[], 150];WatsonUSquareTest[data1, data2]Extract the test statistic from a Watson
test:
data = RandomVariate[NormalDistribution[], 10^3];WatsonUSquareTest[data, NormalDistribution[], "TestStatistic"]Scope (9)
Testing (6)
Perform a Watson
test for normality:
data1 = RandomVariate[NormalDistribution[], 10^4];
data2 = RandomVariate[StudentTDistribution[3], 10^4];The
-value for the normal data is large compared to the
-value for the non-normal data:
WatsonUSquareTest[data1]WatsonUSquareTest[data2]Test the goodness of fit to a particular distribution:
data1 = RandomVariate[NormalDistribution[], 10^3];
data2 = RandomVariate[CauchyDistribution[0, 1], 10^3];WatsonUSquareTest[data1, CauchyDistribution[0, 1]]WatsonUSquareTest[data2, CauchyDistribution[0, 1]]Compare the distributions of two datasets:
data1 = RandomVariate[NormalDistribution[], 10^3];
data2 = RandomVariate[NormalDistribution[], 10^3];WatsonUSquareTest[data1, data2]The two datasets do not have the same distribution:
data3 = RandomVariate[NormalDistribution[0, 1.25], 10^3];WatsonUSquareTest[data1, data3]Test for multivariate normality:
data1 = RandomVariate[BinormalDistribution[.5], 10^3];
data2 = RandomVariate[LaplaceDistribution[1, 2], {10^3, 2}];WatsonUSquareTest[data1]WatsonUSquareTest[data2]Test for goodness of fit to any multivariate distribution:
data1 = RandomVariate[BinormalDistribution[.5], 10^3];
data2 = RandomVariate[𝒹 = LaplaceDistribution[1, 2], {10^3, 2}];𝒟 = ProductDistribution[𝒹, 𝒹];WatsonUSquareTest[data1, 𝒟]WatsonUSquareTest[data2, 𝒟]Create a HypothesisTestData object for repeated property extraction:
data = RandomVariate[NormalDistribution[], 10^5];ℋ = WatsonUSquareTest[data, Automatic, "HypothesisTestData"]The properties available for extraction:
ℋ["Properties"]Reporting (3)
Tabulate the results of the Watson
test:
data = RandomVariate[NormalDistribution[], 100];ℋ = WatsonUSquareTest[data, Automatic, "HypothesisTestData"];ℋ["TestDataTable"]ℋ["PValueTable"]ℋ["TestStatisticTable"]Retrieve the entries from a Watson
test table for custom reporting:
data1 = RandomVariate[NormalDistribution[], 100];
data2 = RandomVariate[NormalDistribution[], 100];ℋ1 = WatsonUSquareTest[data1, Automatic, "TestData"]ℋ2 = WatsonUSquareTest[data2, Automatic, "TestData"]BarChart[{Labeled[ℋ1, "Set 1"], Labeled[ℋ2, "Set 2"]}, ChartLabels -> {"SubscriptBox[D, n]", "p‐value"}]Report test conclusions using "ShortTestConclusion" and "TestConclusion":
data = BlockRandom[SeedRandom[1];RandomVariate[ParetoDistribution[1.05, 2], 100]];ℋ = WatsonUSquareTest[data, ParetoDistribution[1, 2], "HypothesisTestData"];ℋ["ShortTestConclusion"]ℋ["TestConclusion"]//TraditionalFormThe conclusion may differ at a different significance level:
ℋ = WatsonUSquareTest[data, ParetoDistribution[1, 2], "HypothesisTestData", SignificanceLevel -> .001];ℋ["ShortTestConclusion"]ℋ["TestConclusion"]//TraditionalFormOptions (3)
Method (3)
Use Monte Carlo-based methods for a computation formula:
data = RandomVariate[NormalDistribution[], 100];WatsonUSquareTest[data, NormalDistribution[], Method -> "MonteCarlo"]WatsonUSquareTest[data, NormalDistribution[], Method -> Automatic]Set the number of samples to use for Monte Carlo-based methods:
data = RandomVariate[NormalDistribution[], 100];pts = Table[{i, WatsonUSquareTest[data, NormalDistribution[], Method -> {"MonteCarlo", "MonteCarloSamples" -> i}]}, {i, Range[5, 100, 5]}];The Monte Carlo estimate converges to the true
-value with increasing samples:
pval = WatsonUSquareTest[data, NormalDistribution[]];Show[ListLinePlot[pts, PlotRange -> {0, 1}, FrameLabel -> {"Samples", "P-Value"}, Frame -> True, AxesOrigin -> {0, 0}], Graphics[{Dashed, Line[{{0, pval}, {100, pval}}]}]]Set the random seed used in Monte Carlo-based methods:
data = RandomVariate[NormalDistribution[], 100];pts = Table[{i, WatsonUSquareTest[data, NormalDistribution[], Method -> {"MonteCarlo", "RandomSeed" -> i, "MonteCarloSamples" -> 50}]}, {i, Range[1, 10]}];The seed affects the state of the generator and has some effect on the resulting
-value:
pval = WatsonUSquareTest[data, NormalDistribution[]];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}}]}]]Applications (2)
A power curve for the Watson
test:
data = Table[RandomVariate[UniformDistribution[{-4, 4}], {500, i}], {i, n = {5, 7, 10, 15, 20, 25, 30}}];ℋ = Table[WatsonUSquareTest[data[[i, j]], NormalDistribution[]], {i, Length[data]}, {j, Length[data[[i]]]}];pC = Interpolation[Transpose[{n, Table[Probability[x ≤ 0.05, xi], {i, ℋ}]}], InterpolationOrder -> 1];Visualize the approximate power curve:
Plot[pC[x], {x, 5, 30}, PlotRange -> {0, 1}, Ticks -> {n, Automatic}, AxesOrigin -> {0, 0}]Estimate the power of the Watson
test when the underlying distribution is a UniformDistribution[{-4,4}], the test size is 0.05, and the sample size is 12:
pC[12.]A statistics class decides to test a board game spinner for bias. Each of the 50 students in the class spins the spinner once. A device was used to record the angle of rotation in radians for each spin:
data = {25.1, 28.51, 15.58, 7.98, 7.87, 28.9, 28.72, 10.64, 27.33, 23.86, 6.49, 11.02, 8.66, 28.84, 31.14, 24.05, 15.92, 12.66, 20.31, 17.06, 17.45, 21.94, 9.8, 7.26, 11.44, 23.78, 18.83, 13.17, 23.12, 18.06, 21.79, 26.57, 22.11, 21.12, 13.24, 24.26, 18.48, 28.63, 20.51, 8.21, 21.82, 17.09, 30.67, 14.99, 28.42, 21.64, 16.75, 8.06, 9.5, 30.55};ListPlot[Table[{Cos[x], Sin[x]}, {x, data}], AspectRatio -> 1]Convert each measure to a measure on
:
conv[d_] := With[{r = d / 2π}, 2π(r - IntegerPart[r])]cData = conv /@ data;A test for uniformity on the circle shows the spinner to be unbiased:
WatsonUSquareTest[cData, UniformDistribution[{0, 2π}], "TestDataTable"]Properties & Relations (8)
By default, univariate data is compared to a NormalDistribution:
data = RandomVariate[NormalDistribution[2, 3], 10^4];ℋ = WatsonUSquareTest[data, Automatic, "HypothesisTestData"];ℋ["TestDataTable"]The parameters have been estimated from the data:
ℋ["FittedDistribution"]Multivariate data is compared to a MultinormalDistribution by default:
data = RandomVariate[MultinormalDistribution[{1, 2, 3}, IdentityMatrix[3]], 1000];ℋ = WatsonUSquareTest[data, Automatic, "HypothesisTestData"];ℋ["TestDataTable"]ℋ["FittedDistribution"]//TraditionalFormThe parameters of the test distribution are estimated from the data if not specified:
data = RandomVariate[NormalDistribution[1, 2], 1000];WatsonUSquareTest[data, NormalDistribution[μ, σ], "FittedDistribution"]Specified parameters are not estimated:
WatsonUSquareTest[data, NormalDistribution[μ, 2], "FittedDistribution"]WatsonUSquareTest[data, NormalDistribution[1, 2], "FittedDistribution"]Maximum-likelihood estimates are used for unspecified parameters of the test distribution:
data = RandomVariate[ExponentialDistribution[3], 10^3];ℋ = WatsonUSquareTest[data, ExponentialDistribution[λ], "FittedDistribution"]WatsonUSquareTest[data, ExponentialDistribution[λ]]If the parameters are unknown, WatsonUSquareTest applies a correction when possible:
data = RandomVariate[NormalDistribution[3, 4], 10^4];est = EstimatedDistribution[data, NormalDistribution[μ, σ]]The parameters are estimated but no correction is applied:
WatsonUSquareTest[data, est]ℋ = WatsonUSquareTest[data, NormalDistribution[μ, σ], "HypothesisTestData"];The fitted distribution is the same as before, and the
-value is corrected:
ℋ["FittedDistribution"]ℋ["PValue"]Independent marginal densities are assumed in tests for multivariate goodness of fit:
data = RandomVariate[MultinormalDistribution[{0, 0}, {{0.118, 0.252}, {0.252, 0.665}}], 100];WatsonUSquareTest[data, MultinormalDistribution[{0, 0}, {{0.118, 0.252}, {0.252, 0.665}}], "TestStatistic"]The test statistic is identical when independence is assumed:
WatsonUSquareTest[data, MultinormalDistribution[{0, 0}, {{0.118, 0}, {0, 0.665}}], "TestStatistic"]The Watson
statistic can be defined using NExpectation:
n = 10;
h0 = NormalDistribution[1, 2];
data = RandomVariate[h0, n];f[x_] := CDF[h0, x]
Overscript[f, ^ ][x_] := CDF[EmpiricalDistribution[data], x]d[x_] := Overscript[f, ^ ][x] - f[x]
Overscript[d, _] = NExpectation[d[x], xh0];n NExpectation[(d[x] - Overscript[d, _]) ^ 2, xh0]WatsonUSquareTest[data, h0, "TestStatistic"]The Watson
test works with the values only when the input is a TimeSeries:
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];WatsonUSquareTest[ts]WatsonUSquareTest[ts["Values"]]Possible Issues (3)
The Watson
test is not intended for discrete distributions:
data = RandomVariate[DiscreteUniformDistribution[{-10, 10}], 35];WatsonUSquareTest[data, DiscreteUniformDistribution[{-10, 10}]]The continuity correction typically does a good job of preserving the size of the test:
sim = RandomVariate[DiscreteUniformDistribution[{-10, 10}], {500, 35}];p = Quiet[WatsonUSquareTest[#, DiscreteUniformDistribution[{-10, 10}]]]& /@ sim;Show[ListLinePlot[Table[{α, Probability[pv ≤ α, pvp]}, {α, .01, 1, .01}]], Plot[x, {x, 0, 1}, PlotStyle -> Dashed]]This may not be the case in some situations:
sim = RandomVariate[DiscreteUniformDistribution[{1, 3}], {500, 35}];p = Quiet[WatsonUSquareTest[#, DiscreteUniformDistribution[{1, 3}]]]& /@ sim;Show[ListLinePlot[Table[{α, Probability[pv ≤ α, pvp]}, {α, .01, 1, .01}]], Plot[x, {x, 0, 1}, PlotStyle -> Dashed]]Use Monte Carlo methods or PearsonChiSquareTest in these cases:
WatsonUSquareTest[sim[[1]], DiscreteUniformDistribution[{1, 3}], Method -> "MonteCarlo"]PearsonChiSquareTest[sim[[1]], DiscreteUniformDistribution[{1, 3}]]The Watson
test is not valid for some distributions when parameters have been estimated from the data:
data = RandomVariate[BetaDistribution[1, 2], 100];WatsonUSquareTest[data, BetaDistribution[1, b]]Provide parameter values if they are known:
WatsonUSquareTest[data, BetaDistribution[1, 2]]Alternatively, use Monte Carlo methods to approximate the
-value:
WatsonUSquareTest[data, BetaDistribution[1, b], Method -> "MonteCarlo"]data = RandomVariate[NormalDistribution[], 1000];WatsonUSquareTest[Join[data, {First[data]}]]PearsonChiSquareTest[Join[data, {First[data]}]]Differences may be more apparent with larger numbers of ties:
WatsonUSquareTest[Join[data, data]]PearsonChiSquareTest[Join[data, data]]Neat Examples (1)
Compute the statistic when the null hypothesis
is true:
data = RandomVariate[NormalDistribution[], {500, 100}];T1 = WatsonUSquareTest[#, NormalDistribution[], "TestStatistic"]& /@ data;The test statistic given a particular alternative:
T2 = WatsonUSquareTest[#, LaplaceDistribution[1, 2], "TestStatistic"]& /@ data;Compare the distributions of the test statistics:
SmoothHistogram[{T1, T2}, Filling -> Axis, PlotLegends -> {"SubscriptBox[H, 0] is True", "SubscriptBox[H, 0] is False"}, PlotRange -> All]Related Guides
History
Text
Wolfram Research (2010), WatsonUSquareTest, Wolfram Language function, https://reference.wolfram.com/language/ref/WatsonUSquareTest.html.
CMS
Wolfram Language. 2010. "WatsonUSquareTest." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/WatsonUSquareTest.html.
APA
Wolfram Language. (2010). WatsonUSquareTest. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/WatsonUSquareTest.html
BibTeX
@misc{reference.wolfram_2026_watsonusquaretest, author="Wolfram Research", title="{WatsonUSquareTest}", year="2010", howpublished="\url{https://reference.wolfram.com/language/ref/WatsonUSquareTest.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_watsonusquaretest, organization={Wolfram Research}, title={WatsonUSquareTest}, year={2010}, url={https://reference.wolfram.com/language/ref/WatsonUSquareTest.html}, note=[Accessed: 13-June-2026]}