adaptive.chi.square {CryptRndTest} | R Documentation |
Adaptive Chi-Square Test
Description
Performs Adaptive Chi-Square test of Ryabko et al.(2004) to evaluate the randomness of an RNG.
Usage
adaptive.chi.square(x, B, S, alpha = 0.05, prop=0.5, 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 into. |
S |
the number of subsets where letters of an alphabet are combined, and |
alpha |
a predetermined value of significance level with the default value of 0.05. |
prop |
a predetermined value of proportion of training data set. |
bit |
if |
Details
It is possible to apply adaptive Chi-Square to smaller samples than that required for the regular chi-square test.
If x
contains a sequence of bits, then x
should be a matrix of B
xk
, where k
is the number of words (integers) generated by the RNG of interest. Otherwise, x
is a k
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.
The degrees of freedom of the resulting chi-square test is S-1
. The value of S
should be much less than 2^B
.
Value
statistic |
calculated value of the test statistic. |
p.value |
p-value of the test. |
result.acsq |
returns 0 if H0 is rejected and 1 otherwise. |
Author(s)
Haydar Demirhan
Maintainer: Haydar Demirhan <haydarde@hacettepe.edu.tr>
References
Ryabko, B.Ya., Stognienko, V.S., Shokin Yu.I., A new test for randomness and its application to some cryptographic problems. Journal of Statistical Planning and Inference (2004), 123, 365–376.
Examples
RNGkind(kind = "Super-Duper")
B=16 # Bit length is 16.
k=5000 # Generate 5000 integers.
x=0
x=round(runif(k,0,(2^B-1)))
S=2 # Divide alphabet to two subsets.
alpha = 0.05
test=adaptive.chi.square(x, B, S, alpha, bit =FALSE)
print(test)