### Basic Examples

Basic Examples

Generate a sequence of random reals and apply a discrete cosine transform-based test:

sequence=RandomReal[{0,1},1000];

In[]:=

Visualize the sequence:

ArrayPlotPartition[sequence,16],

In[]:=

Out[]=

[sequence,"TestStatistic"]

In[]:=

0.0186997

Out[]=

[sequence,"PValue"]

In[]:=

0.559604

Out[]=

Generate a sequence of random integers and apply a discrete cosine transform-based test:

sequence=RandomInteger[{0,1},1000];

In[]:=

Visualize the sequence:

ArrayPlotPartition[sequence,16],

In[]:=

Out[]=

[sequence,"TestStatistic"]

In[]:=

0.0129432

Out[]=

[sequence,"PValue"]

In[]:=

0.967207

Out[]=

### Scope

Scope

Attempt to reject a non-random sequence:

subsequence=RandomInteger[{0,1},100];

In[]:=

sequence=Flatten[Table[subsequence,20]];

In[]:=

ArrayPlotPartition[Take[sequence,200],25],

In[]:=

Out[]=

[sequence,"TestStatistic"]

In[]:=

0.298392

Out[]=

[sequence,"PValue"]

In[]:=

0.

Out[]=

### Applications

Applications

Test to see if rule 30 is random according to the spectral test:

rule30seq=CellularAutomaton[30,{{1},0},{10000,0}]〚1〛;

In[]:=

ArrayPlotPartition[Take[rule30seq,100],25],

In[]:=

Out[]=

[rule30seq]

In[]:=

0.226717

Out[]=

### Possible Issues

Possible Issues

For non-random data, the Kolmogorov–Smirnov test, a part of the entire test, may return ties. Observing such ties is a strong indicator that the data is non–random:

### Neat Examples

Neat Examples

Visualize the sampling distribution of the test statistic: