book.stack {CryptRndTest} | R Documentation |
Book Stack Test
Description
Performs Book Stack test of Ryabko and Monarev (2005) to evaluate the randomness of an RNG. The Chi-Square test is applied as the goodness-of-fit test.
Usage
book.stack(x, B, k=2, alpha=0.05, bit=FALSE)
Arguments
x |
a vector or matrix that includes random data. See details for further information. |
B |
the length of words (B-bit) that the chippered file will be divided. |
k |
the number of subsets that the alphabet will be divided. It should be chosen to ensure |
alpha |
a predetermined value of significance level with the default value of 0.05. |
bit |
if |
Details
If x
contains a sequence of bits, then x
should be a matrix of B
xN
, where N
is the number of words (integers) generated by the RNG of interest. Otherwise, x
is an N
x1
vector of the words. Because bits will be converted to base-10 before application of the test, implementation time will be shorter with integer input.
Optimal value of N
, which also represents the length of sample that is composed of B-bit words, is obtained by the optimal length of sample composed of bits (n
) that is given by Ryabko and Monarev (2005) as n=B(2^(B/2))
. For example, if B=16
, then n=4096
and the legth of alphabet is 65536. In this case, we need to enter 4096 bits or N=4096/16=256
integers. However, under the setting B=32
, the length of alphabet is 2^32 and we need to enter 65536. Note that it is hard to implement the test for B>32
due to the memory overflows. Therefore, this test is applicable for smaller values of B
.
In this test, because there is no asymptotic theoretical distribution introduced, only chi-square test is applied as goodness-of-fit test.
Value
statistic |
calculated value of the test statistic. |
p.value |
p-value of the Chi-Square test. |
BS.result |
returns 0 if H0 is rejected and 1 otherwise. |
Author(s)
Haydar Demirhan
Maintainer: Haydar Demirhan <haydarde@hacettepe.edu.tr>
References
Ryabko, B.Ya., Monarev, V.A., Using information theory approach to randomness testing. Journal of Statistical Planning and Inference (2005), 133, 95–110.
Examples
RNGkind(kind = "L'Ecuyer-CMRG")
B=8 # Bit length is 8.
n=B*(2^(B/2)) # Number of required bits.
N=n/B # Number of integers to be generated.
x=round(runif(N,0,(2^B-1)))
k=2 # Divide alphabet to two sub-sets.
alpha=0.05
test=book.stack(x, B, k, alpha, bit = FALSE)
print(test)