DCUBE
Required Arguments
X — Vector of length NRAN containing the data elements to be added to the test on this invocation. (Input)
COUNT — NCELL by NCELL by NCELL array containing the tabulations for the triplets test. (Output, if IDO = 0 or 1. Input/Output, if IDO = 2 or 3.)
EXPECT — Expected number of counts in each cell. (Output, if IDO = 0 or 3; not referenced otherwise)
CHISQ — Chi‑squared statistic for testing the null hypothesis of a uniform distribution. (Output, if IDO = 0 or 3; not referenced otherwise)
DF — Degrees of freedom for chi‑squared. (Output, if IDO = 0 or 3; not referenced otherwise)
PROB — Probability of a larger chi‑squared. (Output, if IDO = 0 or 3; not referenced otherwise)
Optional Arguments
IDO — Processing Option. (Input)
Default: IDO = 0.
IDO |
Action |
0 |
This is the only invocation of DCUBE, and all the data are input at once. |
1 |
This is the first invocation of DCUBE, and additional calls will be made. Initialization and updating for the NRAN data elements are performed. |
2 |
This is an intermediate invocation of DCUBE, and updating for the NRAN data elements is performed. |
3 |
This is the final invocation of DCUBE for this data set. Updating for the NRAN data elements is performed, followed by the wrap‑up computations. |
NRAN — Number of random deviates currently input in X. (Input)
NRAN may be positive or zero on any invocation of DCUBE. NRAN must be evenly divisible by 3.
Default: NRAN = size (X,1).
NCELL — The number of equiprobable cells on each of the three axes into which the triplets are to be tabulated. (Input)
Each set of three data elements is tabulated into a three dimensional cube, each axis of which has NCELL cells.
Default: NCELL = size (COUNT,1).
LDCOUN — Leading and second dimension of matrix COUNT exactly as specified in the dimension statement in the calling program. (Input)
Default: LDCOUN = size (COUNT,1).
FORTRAN 90 Interface
Generic: CALL DCUBE (X, COUNT, EXPECT, CHISQ, DF, PROB [, …])
Specific: The specific interface names are S_DCUBE and D_DCUBE.
FORTRAN 77 Interface
Single: CALL DCUBE (IDO, NRAN, X, NCELL, COUNT, LDCOUN, EXPECT, CHISQ, DF, PROB)
Double: The double precision name is DDCUBE.
Description
Routine DCUBE computes the triplets test on a sequence of hypothesized pseudorandom uniform (0, 1) deviates. The triplets test is computed as follows: Each set of three successive deviates, X1, X2, and X3, is tallied into one of m3 equal sized cubes, where m = NCELL. Let i = [mX1] + 1, j = [mX2] + 1, and k = [mX3] + 1. For the triplet (X1, X2, X3), COUNT(i, j, k) is incremented.
Under the null hypothesis of pseudorandom uniform(0, 1) deviates, the m3 cells are equally probable and each has expected value e = n/m3, where n is the number of triplets tallied. An approximate chi‑squared statistic is computed as
where oijk = COUNT(i, j, k).
The computed chi‑squared has m3 ‑ 1 degrees of freedom, and the null hypothesis of pseudorandom uniform (0, 1) deviates is rejected if X2 is too large.
Comments
Informational error
Type |
Code |
Description |
4 |
1 |
The sum of the counts is equal to zero. There are no data elements so the chi‑squared statistic cannot be computed. CHISQ and PROB are set to NaN (not a number). |
Example
In the following example, 2001 deviates generated by IMSL routine RNUN (see Chapter 18, “Random Number Generation”) are input to DCUBE, and tabulated in 27 equally sized cubes. In the example, the null hypothesis is not rejected.
USE IMSL_LIBRARIES
IMPLICIT NONE
INTEGER LDCOUN, NCELL, NRAN
PARAMETER (LDCOUN=3, NCELL=3, NRAN=2001)
!
INTEGER I, NOUT
REAL CHISQ, COUNT(LDCOUN,LDCOUN,NCELL), DF, EXPECT, PROB, &
X(NRAN)
!
CALL RNSET (123457)
! Generate the random numbers
CALL RNUN (X)
!
CALL DCUBE (X, COUNT, EXPECT, CHISQ, DF, PROB)
!
DO 10 I=1, NCELL
CALL WRRRN ('COUNT', COUNT(1:,1:,I))
10 CONTINUE
CALL UMACH (2, NOUT)
WRITE (NOUT,*) ' EXPECT = ', EXPECT
WRITE (NOUT,*) ' CHISQ = ', CHISQ
WRITE (NOUT,*) ' DF = ', DF
WRITE (NOUT,*) ' PROB = ', PROB
END
Output
COUNT
1 2 3
1 26.00 27.00 24.00
2 20.00 17.00 32.00
3 30.00 18.00 21.00
COUNT
1 2 3
1 20.00 16.00 26.00
2 22.00 22.00 27.00
3 30.00 24.00 26.00
COUNT
1 2 3
1 28.00 30.00 22.00
2 23.00 24.00 22.00
3 33.00 30.00 27.00
EXPECT = 24.7037
CHISQ = 21.7631
DF = 26.0000
PROB = 0.701586