PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_nonpar_gofstat_anddar_unif (g08cj)
Purpose
nag_nonpar_gofstat_anddar_unif (g08cj) calculates the Anderson–Darling goodness-of-fit test statistic and its probability for the case of standard uniformly distributed data.
Syntax
Description
Calculates the Anderson–Darling test statistic
(see
nag_nonpar_gofstat_anddar (g08ch)) and its upper tail probability by using the approximation method of
Marsaglia and Marsaglia (2004) for the case of uniformly distributed data.
References
Anderson T W and Darling D A (1952) Asymptotic theory of certain ‘goodness-of-fit’ criteria based on stochastic processes Annals of Mathematical Statistics 23 193–212
Marsaglia G and Marsaglia J (2004) Evaluating the Anderson–Darling distribution J. Statist. Software 9(2)
Parameters
Compulsory Input Parameters
- 1:
– logical scalar
-
Set if the observations are sorted in ascending order; otherwise the function will sort the observations.
- 2:
– double array
-
, for , the observations.
Constraint:
if , the values must be sorted in ascending order. Each must lie in the interval .
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the dimension of the array
y.
, the number of observations.
Constraint:
.
Output Parameters
- 1:
– double array
-
If , the data sorted in ascending order; otherwise the array is unchanged.
- 2:
– double scalar
-
, the Anderson–Darling test statistic.
- 3:
– double scalar
-
, the upper tail probability for .
- 4:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
-
-
Constraint: .
-
-
and the data in
y is not sorted in ascending order.
-
-
The data in
y must lie in the interval
.
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
Accuracy
Probabilities greater than approximately are accurate to five decimal places; lower value probabilities are accurate to six decimal places.
Further Comments
None.
Example
This example calculates the statistic and its -value for uniform data obtained by transforming exponential variates.
Open in the MATLAB editor:
g08cj_example
function g08cj_example
fprintf('g08cj example results\n\n');
x = [0.4782745, 1.2858962, 1.1163891, 2.0410619, 2.2648109, 0.0833660, ...
1.2527554, 0.4031288, 0.7808981, 0.1977674, 3.2539440, 1.8113504, ...
1.2279834, 3.9178773, 1.4494309, 0.1358438, 1.8061778, 6.0441929, ...
0.9671624, 3.2035042, 0.8067364, 0.4179364, 3.5351774, 0.3975414, ...
0.6120960, 0.1332589];
mu = 1.65;
y = 1 - exp(-x/mu);
issort = false;
[y, a2, p, ifail] = g08cj( ...
issort, y);
fprintf('H0: data from exponential distribution with mean %10.4e\n', mu);
fprintf('Test statistic, A-squared: %8.4f\n', a2);
fprintf('Upper tail probability: %8.4f\n', p);
g08cj example results
H0: data from exponential distribution with mean 1.6500e+00
Test statistic, A-squared: 0.1830
Upper tail probability: 0.9945
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015