Test of randomization of non-repeating numbers sample I have a sample of non-repeating numbers 45...18024. The numbers are supposed to be distributed in a random order. How can I check the strength of randomization? Which tests in SPSS can I use to ensure their randomness?
 A: I think a Wald-Wolfowitz runs test would be adequate here. I do not know about SPSS, but chances are that this test will be available in that package, as is in many others.
A: As stated in the remarks, there are many possibilities. F. Tusell proposed a solution, you may also run the Wald-Wolfowitz test on the sign of the differences between successive terms.
I’ll try to propose something funny. It’s only approximate but I wanted to see how it behaves. 
I consider a random ordering $X_1, \dots, X_n$ of $\{1, 2, \dots, n\}$ (you can always go back to this situation, e.g. relabeling your numbers in increasing order). I let $Y_i = X_{i+1} - X_i$ for $i= 1, \dots, n-1$.
Under the hypothesis of a random ordering, the $Y_i$ are identically distributed, but not independent. I’ll make the assumption that if $n$ is large, it does not matter much. 
Let $\kappa = n(n-1)$. The law of each of the $Y_i$'s is given by
$$ \begin{aligned} 
Pr( Y = n-1 ) = Pr(Y = 1-n) &= {1 \over \kappa} \\
Pr( Y = n-2 ) = Pr(Y = 2-n) &= {2 \over \kappa} \\
\vdots \\
Pr( Y = 1 ) = Pr(Y = -1) &= {n-1 \over \kappa}
\end{aligned}$$
D’où une cdf 
$$ F(y) = \begin{cases}
\displaystyle {1 \over 2 \kappa} (n+y)(n+y+1) & \text{if } y < 0 \\
\displaystyle 1 - {1 \over 2 \kappa} (n-y-1)(n-y) & \text{if } y \ge 0
\end{cases}$$
We will compare the empirical cdf obtained from the $Y_i$'s to the cdf (here we neglect the non-independence of the $Y_i$'s).
Here are two graphs to have a first look.
cdf <- function(y, n) {
  k <- n*(n-1);
  y <- floor(y);
  ifelse(y < -(n-1), 0,
    ifelse(y > n-1, 1,
      ifelse(y < 0, (n+y)*(n+y+1), 2*k-(n-y-1)*(n-y))/(2*k)
    )
  )
}

par(mfrow=c(1,2))
set.seed(1)
f <- ecdf( diff(sample.int(25)) )
t <- seq(-26, 26, length=1001)
plot(t, f(t), type="l")
lines(t, cdf(t,25), col="red")

f <- ecdf( diff(sample.int(100)) )
t <- seq(-100, 100, length=1001)
plot(t, f(t), type="l")
lines(t, cdf(t,100), col="red")


This looks promising. However the experiments show that Kolmogrov-Smirnov is overly conservative! Is this because the dependency between the $Y_i$ produces a too good fit -- or is that because the distribution is not continuous? 
The obvious solution is too use a Monte-Carlo method to get the empirical distribution of a deviance statistic... It can be computed as this.
stat <- function(x) {
  n <- length(x)
  f <- ecdf( diff(x) )
  a <- seq(-n,n)
  max( abs(f(a) - cdf(a,n)) )
}

So let's compute e.g. 10,000 values under the null.
> D <- replicate(1e4, stat( sample.int(1000) ))


Compare with an imperfectly shuffled sample:
> stat(  c(sample(1:500),sample(501:1000)))
[1] 0.1755706

It was fun.
