({{, (RefLink[KuiperTest, paclet:ref/KuiperTest])[data] 
tests whether data is normally distributed using the Kuiper test.}, {, (RefLink[KuiperTest, paclet:ref/KuiperTest])[data,dist] 
tests whether data is distributed according to dist using the Kuiper test.}, {, (RefLink[KuiperTest, paclet:ref/KuiperTest])[data,dist,"property"] 
returns the value of "property".}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[KuiperTest, paclet:ref/KuiperTest]) performs the Kuiper goodness-of-fit test with null hypothesis (Subscript[H, 0]) that data was drawn from a population with distribution dist and alternative hypothesis (Subscript[H, a]) that it was not.

By default a probability value or p-value is returned.

A small p-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 {(Subscript[x, 1]),(Subscript[x, 2]),…} or multivariate {{(Subscript[x, 1]),(Subscript[y, 1]),…},{(Subscript[x, 2]),(Subscript[y, 2]),…},…}.

The Kuiper test assumes that the data came from a continuous distribution.

The Kuiper test effectively uses a test statistic based on (sup_(d(x)>0))((OverHat[F])(x)-F(x) )-(inf_(d(x)<0))((OverHat[F])(x)-F(x))  where (OverHat[F])(x) is the empirical (RefLink[CDF, paclet:ref/CDF]) of data and F(x) is the (RefLink[CDF, paclet:ref/CDF]) of dist.

For multivariate tests, the sum of the univariate marginal p-values is used and is assumed to follow a (RefLink[UniformSumDistribution, paclet:ref/UniformSumDistribution]) under (Subscript[H, 0]).

(RefLink[KuiperTest, paclet:ref/KuiperTest])[data,dist,"HypothesisTestData"] returns a (RefLink[HypothesisTestData, paclet:ref/HypothesisTestData]) object htd that can be used to extract additional test results and properties using the form htd["property"].

(RefLink[KuiperTest, paclet:ref/KuiperTest])[data,dist,"property"] can be used to directly give the value of "property".

Properties related to the reporting of test results include:

The following properties are independent of which test is being performed.

Properties related to the data distribution include:

The following options can be given:

For a test for goodness-of-fit, a cutoff α is chosen such that (Subscript[H, 0]) is rejected only if p<α. The value of α used for the "TestConclusion" and "ShortTestConclusion" properties is controlled by the (RefLink[SignificanceLevel, paclet:ref/SignificanceLevel]) option. By default α is set to 0.05.

With the setting (RefLink[Method, paclet:ref/Method])->"MonteCarlo", k datasets of the same length as the input (Subscript[s, i]) are generated under (Subscript[H, 0]) using the fitted distribution. The (RefLink[EmpiricalDistribution, paclet:ref/EmpiricalDistribution]) from (RefLink[KuiperTest, paclet:ref/KuiperTest])[(Subscript[s, i]),dist,"TestStatistic"] is then used to estimate the p-value.

OpenersPrimaryExamplesSection(Spacer1)Examples  (29)

OpenersExampleSection0(Spacer1)Basic Examples  (4)

Perform a Kuiper test for normality:

data=RandomVariate[NormalDistribution[],(10^4)];

KuiperTest[data]

Test the fit of some data to a particular distribution:

data=RandomVariate[LaplaceDistribution[1,2],(10^3)];

KuiperTest[data,LaplaceDistribution[1,2]]

Compare the distributions of two datasets:

data1=RandomVariate[NormalDistribution[],100];

data2=RandomVariate[NormalDistribution[],150];

KuiperTest[data1,data2]

Extract the test statistic from a Kuiper test:

data=RandomVariate[NormalDistribution[],(10^3)];

KuiperTest[data,NormalDistribution[],"TestStatistic"]

OpenersExampleSection1(Spacer1)Scope  (9)

Perform a Kuiper test for normality:

data1=RandomVariate[NormalDistribution[],(10^4)];
data2=RandomVariate[StudentTDistribution[3],(10^4)];

The p-value for the normal data is large compared to the p-value for the non-normal data:

KuiperTest[data1]

KuiperTest[data2]

Test the goodness-of-fit to a particular distribution:

data1=RandomVariate[NormalDistribution[],(10^3)];
data2=RandomVariate[CauchyDistribution[0,1],(10^3)];

KuiperTest[data1,CauchyDistribution[0,1]]

KuiperTest[data2,CauchyDistribution[0,1]]

Compare the distributions of two datasets:

data1=RandomVariate[NormalDistribution[],(10^3)];
data2=RandomVariate[NormalDistribution[],(10^3)];

KuiperTest[data1,data2]

The two datasets do not have the same distribution:

data3=RandomVariate[NormalDistribution[0,1.25],(10^3)];

KuiperTest[data1,data3]

Test for multivariate normality:

data1=RandomVariate[BinormalDistribution[.5],(10^3)];
data2=RandomVariate[LaplaceDistribution[1,2],{(10^3),2}];

KuiperTest[data1]

KuiperTest[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[𝒹,𝒹];

KuiperTest[data1,𝒟]

KuiperTest[data2,𝒟]

Create a (RefLink[HypothesisTestData, paclet:ref/HypothesisTestData]) object for repeated property extraction:

data=RandomVariate[NormalDistribution[],(10^5)];

ℋ=KuiperTest[data,Automatic,"HypothesisTestData"]

The properties available for extraction:

ℋ["Properties"]

OpenersExampleSubsection0(Spacer1)Reporting  (3)

Tabulate the results of the Kuiper test:

data=RandomVariate[NormalDistribution[],100];

ℋ=KuiperTest[data,Automatic,"HypothesisTestData"];

The full test table:

ℋ["TestDataTable"]

A p-value table:

ℋ["PValueTable"]

The test statistic:

ℋ["TestStatisticTable"]

Retrieve the entries from a Kuiper test table for custom reporting:

data1=RandomVariate[NormalDistribution[],100];
data2=RandomVariate[NormalDistribution[],100];

ℋ1=KuiperTest[data1,Automatic,"TestData"]

ℋ2=KuiperTest[data2,Automatic,"TestData"]

BarChart[{Labeled[ℋ1,"Set 1"],Labeled[ℋ2,"Set 2"]},ChartLabels->{"(Subscript[D, n])","p\[Hyphen]value"}]

Report test conclusions using "ShortTestConclusion" and "TestConclusion":

data=BlockRandom[SeedRandom[1];RandomVariate[ParetoDistribution[1.05,2],100]];

ℋ=KuiperTest[data,ParetoDistribution[1,2],"HypothesisTestData"];

ℋ["ShortTestConclusion"]

ℋ["TestConclusion"]//TraditionalForm

The conclusion may differ at a different significance level:

ℋ=KuiperTest[data,ParetoDistribution[1,2],"HypothesisTestData",SignificanceLevel->.001];

ℋ["ShortTestConclusion"]

ℋ["TestConclusion"]//TraditionalForm

OpenersExampleSection2(Spacer1)Options  (3)

OpenersExampleSubsection1(Spacer1)Method  (3)

Use Monte Carlo-based methods for a computation formula:

data=RandomVariate[NormalDistribution[],100];

KuiperTest[data,NormalDistribution[],Method->"MonteCarlo"]

KuiperTest[data,NormalDistribution[],Method->Automatic]

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

data=RandomVariate[NormalDistribution[],100];

pts=Table[{i,KuiperTest[data,NormalDistribution[],Method->{"MonteCarlo","MonteCarloSamples"->i}]},{i,Range[5,250,15]}];

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

pval=KuiperTest[data,NormalDistribution[]];

Show[ListLinePlot[pts,PlotRange->{0,1},FrameLabel->{"Samples","P-Value"},Frame->True,AxesOrigin->{0,0}],Graphics[{Dashed,Line[{{0,pval},{250,pval}}]}]]

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

data=RandomVariate[NormalDistribution[],100];

pts=Table[{i,KuiperTest[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 p-value:

pval=KuiperTest[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}}]}]]

OpenersExampleSection3(Spacer1)Applications  (2)

A power curve for the Kuiper test:

data=Table[RandomVariate[UniformDistribution[{-4,4}],{500,i}],{i,n={5,7,10,15,20,25,30}}];

ℋ=Table[KuiperTest[data[[i,j]],NormalDistribution[]],{i,Length[data]},{j,Length[data[[i]]]}];

pC=Interpolation[Transpose[{n,Table[Probability[x≤0.05,x\[Distributed]i],{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 Kuiper test when the underlying distribution is a (RefLink[UniformDistribution, paclet:ref/UniformDistribution])[{-4,4}], the test size is 0.05, and the sample size is 12:

pC[12.]

Spatial signs transform bivariate data to points on a unit circle and are often used in tests of location. The null hypothesis can be tested by determining whether the spatial signs are significantly clustered:

data1=RandomVariate[MultinormalDistribution[{0,0},IdentityMatrix[2]],100];
data2=RandomVariate[MultinormalDistribution[{2,1},IdentityMatrix[2]],100];

The spatial sign function:

SpatialSign[d_]:=With[{norm=Norm[d]},If[norm==0,ConstantArray[0,Length[d]],(d/norm)]]

Clustering occurs for nonzero mean vectors:

{ListPlot[SpatialSign/@data1,AspectRatio->1,PlotRange->{{-1,1},{-1,1}},ImageSize->Small],ListPlot[SpatialSign/@data2,AspectRatio->1,PlotRange->{{-1,1},{-1,1}},ImageSize->Small]}

A bivariate test for location using spatial signs and Kuiper's test:

KuiperLocationTest[data_,mu0_]:=KuiperTest[ArcSin[(SpatialSign/@Transpose[Transpose[data]-mu0])[[All,2]]],UniformDistribution[{-(π/2),(π/2)}],"TestDataTable"]

{Mean[data1],Mean[data2]}

The test does not reject when the mean is close to the null value:

{KuiperLocationTest[data1,{0,0}],KuiperLocationTest[data2,{2,1}]}

The test rejects the null hypothesis when the mean is not close to the null value:

{KuiperLocationTest[data1,{1,1}],KuiperLocationTest[data2,{1,2}]}

OpenersExampleSection4(Spacer1)Properties & Relations  (7)

By default, univariate data is compared to a (RefLink[NormalDistribution, paclet:ref/NormalDistribution]):

data=RandomVariate[NormalDistribution[2,3],(10^4)];

ℋ=KuiperTest[data,Automatic,"HypothesisTestData"];

ℋ["TestDataTable"]

The parameters have been estimated from the data:

ℋ["FittedDistribution"]

Multivariate data is compared to a (RefLink[MultinormalDistribution, paclet:ref/MultinormalDistribution]) by default:

data=RandomVariate[MultinormalDistribution[{1,2,3},IdentityMatrix[3]],1000];

ℋ=KuiperTest[data,Automatic,"HypothesisTestData"];

ℋ["TestDataTable"]

ℋ["FittedDistribution"]//TraditionalForm

The parameters of the test distribution are estimated from the data if not specified:

data=RandomVariate[NormalDistribution[1,2],1000];

KuiperTest[data,NormalDistribution[μ,σ],"FittedDistribution"]

Specified parameters are not estimated:

KuiperTest[data,NormalDistribution[μ,2],"FittedDistribution"]

KuiperTest[data,NormalDistribution[1,2],"FittedDistribution"]

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

data=RandomVariate[ExponentialDistribution[3],(10^3)];

ℋ=KuiperTest[data,ExponentialDistribution[λ],"FittedDistribution"]

KuiperTest[data,ExponentialDistribution[λ]]

If the parameters are unknown, (RefLink[KuiperTest, paclet:ref/KuiperTest]) 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:

KuiperTest[data,est]

ℋ=KuiperTest[data,NormalDistribution[μ,σ],"HypothesisTestData"];

The fitted distribution is the same as before and the p-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];

KuiperTest[data,MultinormalDistribution[{0,0},{{0.118,0.252},{0.252,0.665}}],"TestStatistic"]

The test statistic is identical when independence is assumed:

KuiperTest[data,MultinormalDistribution[{0,0},{{0.118,0},{0,0.665}}],"TestStatistic"]

The Kuiper test works with the values only when the input is a (RefLink[TimeSeries, paclet:ref/TimeSeries]):

ts=TimeSeries[];

KuiperTest[ts]

KuiperTest[ts["Values"]]

OpenersExampleSection5(Spacer1)Possible Issues  (3)

The Kuiper test is not intended for discrete distributions:

data=RandomVariate[PoissonDistribution[30],35];

KuiperTest[data,PoissonDistribution[30]]

The test tends to be quite conservative:

sim=RandomVariate[PoissonDistribution[30],{500,35}];

p=Quiet[KuiperTest[#,PoissonDistribution[30]]]&/@sim;

Show[ListLinePlot[Table[{α,Probability[pv≤α,pv\[Distributed]p]},{α,.01,1,.01}]],Plot[x,{x,0,1},PlotStyle->Dashed]]

Use Monte Carlo methods or (RefLink[PearsonChiSquareTest, paclet:ref/PearsonChiSquareTest]) in these cases:

KuiperTest[data,PoissonDistribution[30],Method->"MonteCarlo"]

PearsonChiSquareTest[data,PoissonDistribution[30]]

The Kuiper test is not valid for some distributions when parameters have been estimated from the data:

data=RandomVariate[BetaDistribution[1,2],100];

KuiperTest[data,BetaDistribution[1,b]]

Provide parameter values if they are known:

KuiperTest[data,BetaDistribution[1,2]]

Alternatively, use Monte Carlo methods to approximate the p-value:

KuiperTest[data,BetaDistribution[1,b],Method->"MonteCarlo"]

Ties in the data are ignored:

data=RandomVariate[NormalDistribution[],1000];

KuiperTest[Join[data,{First[data]}]]

PearsonChiSquareTest[Join[data,{First[data]}]]

Differences may be more apparent with larger numbers of ties:

KuiperTest[Join[data,data]]

PearsonChiSquareTest[Join[data,data]]

OpenersExampleSection6(Spacer1)Neat Examples  (1)

Compute the statistic when the null hypothesis (Subscript[H, 0]) is true:

data=RandomVariate[NormalDistribution[],{250,100}];

T1=KuiperTest[#,NormalDistribution[],"TestStatistic"]&/@data;

The test statistic given a particular alternative:

T2=KuiperTest[#,LaplaceDistribution[1,2],"TestStatistic"]&/@data;

Compare the distributions of the test statistics:

SmoothHistogram[{T1,T2},Filling->Axis,PlotLegends->{"(Subscript[H, 0]) is True","(Subscript[H, 0]) is False"},PlotStyle->Thick]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[HypothesisTestData, paclet:ref/HypothesisTestData])  ▪  (RefLink[AndersonDarlingTest, paclet:ref/AndersonDarlingTest])  ▪  (RefLink[KolmogorovSmirnovTest, paclet:ref/KolmogorovSmirnovTest])  ▪  (RefLink[CramerVonMisesTest, paclet:ref/CramerVonMisesTest])  ▪  (RefLink[DistributionFitTest, paclet:ref/DistributionFitTest])  ▪  (RefLink[JarqueBeraALMTest, paclet:ref/JarqueBeraALMTest])  ▪  (RefLink[MardiaCombinedTest, paclet:ref/MardiaCombinedTest])  ▪  (RefLink[MardiaKurtosisTest, paclet:ref/MardiaKurtosisTest])  ▪  (RefLink[MardiaSkewnessTest, paclet:ref/MardiaSkewnessTest])  ▪  (RefLink[PearsonChiSquareTest, paclet:ref/PearsonChiSquareTest])  ▪  (RefLink[ShapiroWilkTest, paclet:ref/ShapiroWilkTest])  ▪  (RefLink[WatsonUSquareTest, paclet:ref/WatsonUSquareTest])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Hypothesis Tests, paclet:guide/HypothesisTests])}})}})