GCD.test | R Documentation |
Performs Greatest Common Divisor (GCD) test of Marsaglia and Tsang (2002) to evaluate the randomness of an RNG. Randomness tests are conducted over two outputs of greatest common divisor operation, namely the number of required iterations and the value of greatest common divisor. The Kolmogorov-Smirnov, Anderson-Darling, Jarque-Bera, and Chi-Square tests are applied as goodness-of-fit tests when the test is conducted over the number of required iterations. The Kolmogorov-Smirnov and Chi-Square tests are applied as goodness-of-fit tests when the test is conducted over the value of greatest common divisor.
GCD.test(x, B = 32, KS = TRUE, CSQ = TRUE, AD = TRUE, JB = TRUE, test.k = TRUE, test.g = TRUE, mu, sd, alpha = 0.05)
x |
an N*2 matrix of integers that includes random data. See details for further information. |
B |
the length of words (B-bit). |
KS |
if |
CSQ |
if |
AD |
if |
JB |
if |
test.k |
if |
test.g |
if |
mu |
the mean of theoretical normal distribution that the number of required iterations follows. |
sd |
the standard deviation of theoretical normal distribution that the number of required iterations follows. |
alpha |
a predetermined value of significance level with the default value of 0.05. |
Total number of integers to be tested is divided into two sets and entered as x
. The GCD operation is applied to each row of x
.
The number of required iterations follows a normal distribution with parameters mu
and sd
. Values of mu
and sd
are obtained by Monte Carlo simulation and given by Marsaglia and Tsang (2002) for 32-bit setting. We obtained values of mu
and sd
for other bit settings as mu=4.2503, sd=1.650673
for 8-bits, mu=8.8772, sd=2.38282
for 16-bits, ...for 24-bits,...
sig.value.k |
a 4 x 1 vector of p-values. Elements of |
sig.value.g |
a 2 x 1 vector of p-values. Elements of |
KS.result.k |
returns 0 if H0 is rejected and 1 otherwise in Kolmogorov-Smirnov goodness-of-fit test conducted over the number of required iterations. |
CSQ.result.k |
returns 0 if H0 is rejected and 1 otherwise in Chi-Square goodness-of-fit test conducted over the number of required iterations. |
JB.result.k |
returns 0 if H0 is rejected and 1 otherwise in Jarque-Bera goodness-of-fit test conducted over the number of required iterations. |
AD.result.k |
returns 0 if H0 is rejected and 1 otherwise in Anderson-Darling goodness-of-fit test conducted over the number of required iterations. |
KS.result.g |
returns 0 if H0 is rejected and 1 otherwise in Kolmogorov-Smirnov goodness-of-fit test conducted over the value of greatest common divisor. |
CSQ.result.g |
returns 0 if H0 is rejected and 1 otherwise in Chi-Square goodness-of-fit test conducted over the value of greatest common divisor. |
Haydar Demirhan
Maintainer: Haydar Demirhan <haydarde@hacettepe.edu.tr>
Marsaglia, G., Tsang, W.W., Some Difficult-to-pass tests of randomness. Journal of Statistical Software (2002), 7(3).
See the function GCD
that provides detailed results for the greatest common divisor operation.
RNGkind(kind = "L'Ecuyer-CMRG") B=16 # Bit length is 16. k=250 # Generate 250 integers. x=array(0,dim=c(k,2)) x[,1]=round(runif(k,0,(2^B-1))) x[,2]=round(runif(k,0,(2^B-1))) mu=8.8772 sd=2.38282 alpha = 0.05 test=GCD.test(x,B=B,KS=TRUE,CSQ=TRUE,AD=TRUE,JB=TRUE, test.k=TRUE,test.g=TRUE,mu=mu,sd=sd,alpha=alpha) print(test)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.