Testing randomness
- From: "\"Luis A. Afonso\"" <licas_@xxxxxxxxxxx>
- Date: Sat, 12 Nov 2005 15:46:49 EST
Let S=(xj) be a sample of size n drawn from a Population P. We want to test is S is random. (H0, null Hypotheses).
Optionally we can find the ranks of xj,
For each element j we define u_j the number of elements that are at its right and are greater than it. The sample statistics is the sum of all u_j. (ties are not allowed).
Example (n=5)
___________2___4___5___1___3
__________(3)__(1)__(0)__(1)___u= 5
The objective is to find if u does not reject H0.
*****
Method (confidence intervals, significance level 5%).
For each string of whole numbers (from 1 to n) simulated at random u was evaluated and 1 added at the respective memory. After analyzing 20000 strings the 5% lower and the 5% upper tails are evaluated. Note that as the sample statistics u is discontinues the cumulative percent values (2.5 and 97.5) are not exactly attained.
TABLE:
n= 05 p(001, 009] = 94,8%______
p(u<=001) = 4,3%__p(u<=009) = 99,1%
n=10 p(012, 033] = 94,1%
p(u<=012) = 3,5%__p(u<=033) = 97,7%
n=15 p(033, 072] = 94,7%
p(u<=033) = 3,0%__p(u<=072) = 97,7%
n=20 p(065, 125] = 94,9%
p(u<=065) = 2,7%__p(u<=125) = 97,6%
n= 25 p(108, 192] = 95,0%
p(u<=108) = 2.7%__p(u<=192) = 97,7%
*****
REM "P0"
CLS
RANDOMIZE TIMER
INPUT " size = "; sz
DIM x(sz), y(sz), have(sz * sz)
maxx = (sz * (sz - 1)) / 2
all = 20000
FOR v = 1 TO all
FOR jj = 1 TO sz: x(jj) = 1: NEXT jj
FOR j = 1 TO sz
2 h = INT(RND * sz) + 1
IF x(h) = 0 THEN GOTO 2
y(h) = j
x(h) = 0
NEXT j
FOR i1 = 1 TO sz - 1
z = y(i1): s = 0
FOR i2 = i1 + 1 TO sz
IF y(i2) > z THEN s = s + 1
NEXT i2
sf = sf + s
NEXT i1
have(sf) = have(sf) + 1
sf = 0
NEXT v: vc(1) = .025 * all: vc(2) = .975 * all
FOR d = 1 TO 2
s = 0
FOR sff = 0 TO 9000
s = s + have(sff)
IF s > vc(d) THEN GOTO 30
NEXT sff
30 PRINT sff, s / all
NEXT d
END
____________licas (Luis A. Afonso)
.
- Follow-Ups:
- Re: Testing randomness
- From: \"Luis A. Afonso\"
- Re: Testing randomness
- From: \"Luis A. Afonso\"
- Re: Testing randomness
- From: \"Luis A. Afonso\"
- Re: Testing randomness
- Prev by Date: Computational complexity of finding MLEs?
- Next by Date: Re: a question on queueing theory
- Previous by thread: Computational complexity of finding MLEs?
- Next by thread: Re: Testing randomness
- Index(es):