There is not much relevant information to be found about Runs-Up/Down test on the great web. All I find is more or less just recycling the info than can be found in Knuth, The Art of Computer Programming Volume 2, 1998, pp. 66.
The Runs-Up/Down test should be run on a sample that has no ties between adjacent numbers (see Algorithm AS 157 on JSTOR or Knuth Vol.2). But what to do when I have ties between adjacent elements? My testing samples are random Integer numbers on interval from 0 to as low as 20 (usually the upper limit is around 150). In such sample there will be a lot of ties. The Algorithm AS 157 checks the sample and returns an error if ties are detected. But why should the Runs-Up test be limited to sample without ties?
To avoid ties I decided to check the sample and remove the ties (this lowers the sample size, but it is still well above the recommended minimum of 4000 elements). But then we noticed that the test will Fail badly for RNG on small interval (ex. 0 - 50), but Pass for larger intervals (ex. 0 - 300). Smaller RNG interval will produce more ties than larger interval, so this may be the cause of failed tests. Can anyone explain why?
Anyhow, the removing of ties is not OK because I should not alter the RNG output.
Another idea we had, was to let the ties and just re-define what an Up-Run is. We could say that the up run continues until the next number in a sequence is bigger or equal to previous number. But than what should I do with the length of run that contains ties. Should the run length be increased on a tie or not. Another problem is that I do not know if the matrix used in the algorithm remains the same (probably not).
So the question is: How can Runs-Up/Down test be used on a RNG sample of integers that have ties between adjacent numbers.
Note: The RNG is not causing the failed tests. Also the scaling of RNG output is not the cause (RNG usually outputs Integer from 0 to MAX_INT, this is than scaled to the desired interval). It has been tested on different "known to be good" RNG-s many many times.
Note2: When RNG is used only to produce shuffled arrays it will pass the test. For example, array [0,1,2...,14,15] is shuffled 1000 times to produce the output of length 15000 elements. Of course there can be ties between adjacent elements, but they are much rarer as the tie can occur only where two shuffled arrays "touch".