Last data update: 2014.03.03

R: Topological Binary Test
topological.binaryR Documentation

Topological Binary Test

Description

Performs Topological Binary Test of Alcover et al. (2013) to evaluate the randomness of an RNG. No additional goodness-of-fit test is applied after calculation of test statistic of Topological Binary Test.

Usage

topological.binary(x, B, alpha = 0.05, critical.value)

Arguments

x

a matrix that includes random data in base-2 format. See details for further information.

B

the length of words (B-bit).

alpha

a predetermined value of significance level with the default value of 0.05.

critical.value

a value used to decide whether to reject the null hypothesis at the significance level of alpha. See details for further information.

Details

The argument x should be entered as a matrix of bits of dimension Bxk, where k is the number of words (integers) generated by the RNG of interest.

The argument critical.value should be calculated regarding the value of B. For B = 8,...,16, values of critical.value are tabulated by Alcover et al. (2013) and calculation procedure of critical.value for the values greater than 16 is described therein. The tabulated values can be used if the number of words (k) is equal to 2^B. Otherwise, it should be calculated over the given cumulative distribution function by Alcover et al. (2013). For example, if k=10^4, then critical.value = 9245 and if k=2*10^4, then critical.value = 19999.

Topological binary test is itself constitutes a goodness-of-fit test based on the number of different B-bit patterns among the non-overlapping B-bit blocks composed of the input sequence of bits.

Value

statistic

calculated value of the test statistic.

result.TBT

returns 0 if H0 is rejected and 1 otherwise.

Author(s)

Haydar Demirhan

Maintainer: Haydar Demirhan <haydarde@hacettepe.edu.tr>

References

Alcover, P.M., Guillamon, A., Ruiz, M.C., A new randomness test for bit sequences. Informatica (2013), 24(3), 339–356.

Examples

RNGkind(kind = "Super-Duper")
B=16                          # Bit length is 16.
k=5000                        # Generate 5000 integers.
dat=round(runif(k,0,(2^B-1)))
x=sfsmisc::digitsBase(dat, base= 2, B) #Convert to base 2
alpha = 0.05
critical.value=9245           #Obtained for B = 16
test=topological.binary(x, B, alpha, critical.value)
print(test)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(CryptRndTest)
Loading required package: MissMech
Loading required package: kSamples
Loading required package: SuppDists
Loading required package: sfsmisc
Loading required package: Rmpfr
Loading required package: gmp

Attaching package: 'gmp'

The following objects are masked from 'package:sfsmisc':

    factorize, is.whole

The following objects are masked from 'package:base':

    %*%, apply, crossprod, matrix, tcrossprod

C code of R package 'Rmpfr': GMP using 64 bits per limb


Attaching package: 'Rmpfr'

The following objects are masked from 'package:stats':

    dbinom, dnorm, dpois, pnorm

The following objects are masked from 'package:base':

    cbind, pmax, pmin, rbind

Loading required package: parallel
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/CryptRndTest/topological.binary.Rd_%03d_medium.png", width=480, height=480)
> ### Name: topological.binary
> ### Title: Topological Binary Test
> ### Aliases: topological.binary
> ### Keywords: nonparametric randomness test
> 
> ### ** Examples
> 
> RNGkind(kind = "Super-Duper")
> B=16                          # Bit length is 16.
> k=5000                        # Generate 5000 integers.
> dat=round(runif(k,0,(2^B-1)))
> x=sfsmisc::digitsBase(dat, base= 2, B) #Convert to base 2
> alpha = 0.05
> critical.value=9245           #Obtained for B = 16
> test=topological.binary(x, B, alpha, critical.value)
> print(test)

    Test results for Topological Binary test
    -----------------------------------------
     Value  : 4826
     Result : Reject H0
    -----------------------------------------> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>