bool RNGTester::Test(unsigned char *eps, int n) { double p_value = 1.0 ; std::cout << std::fixed << std::setprecision(6) ; p_value = std::min(p_value, Frequency(n, eps) ) ; p_value = std::min(p_value, BlockFrequency(n/100, n, eps) ) ; p_value = std::min(p_value, Runs(n, eps) ) ; p_value = std::min(p_value, LongestRunOfOnes(n, eps) ) ; //p_value = std::min(p_value, Rank(n, eps) ) ; //p_value = std::min(p_value, DiscreteFourierTransform(n, eps) ) ; //p_value = std::min(p_value, NonOverlappingTemplateMatchings(10, n, eps) ) ; //p_value = std::min(p_value, OverlappingTemplateMatchings(10, n, eps) ) ; p_value = std::min(p_value, Universal(n, eps) ) ; p_value = std::min(p_value, LinearComplexity(1000, n, eps) ) ; p_value = std::min(p_value, Serial(5, n, eps) ) ; //p_value = std::min(p_value, ApproximateEntropy(5, n, eps) ) ; p_value = std::min(p_value, CumulativeSums(n, eps) ) ; //p_value = std::min(p_value, RandomExcursions(n, eps) ) ; //p_value = std::min(p_value, RandomExcursionsVariant(n, eps) ) ; std::cout << "p_value = " << p_value << std::endl ; return (p_value>=0.01) ; }
int main(void) { for(int i=0;i<MY_N;i++) { scanf("%c", &eps[i]) ; eps[i] -= '0' ; if(eps[i]!=0 && eps[i]!=1) i-- ; } //for(int i=0;i<MY_N;i++) eps[i] = rand()%2 ; std::cout << Frequency(MY_N, eps) << std::endl ; std::cout << BlockFrequency(MY_N/100, MY_N, eps) << std::endl ; std::cout << Runs(MY_N, eps) << std::endl ; std::cout << LongestRunOfOnes(MY_N, eps) << std::endl ; //std::cout << Rank(MY_N, eps) << std::endl ; //std::cout << DiscreteFourierTransform(MY_N, eps) << std::endl ; //std::cout << NonOverlappingTemplateMatchings(10, MY_N, eps) << std::endl ; //std::cout << OverlappingTemplateMatchings(10, MY_N, eps) << std::endl ; std::cout << Universal(MY_N, eps) << std::endl ; std::cout << LinearComplexity(1000, MY_N, eps) << std::endl ; std::cout << Serial(5, MY_N, eps) << std::endl ; //std::cout << ApproximateEntropy(5, MY_N, eps) << std::endl ; std::cout << CumulativeSums(MY_N, eps) << std::endl ; //std::cout << RandomExcursions(MY_N, eps) << std::endl ; //std::cout << RandomExcursionsVariant(MY_N, eps) << std::endl ; return 0 ; }
void nist_test_suite() { if ( (testVector[0] == 1) || (testVector[TEST_FREQUENCY] == 1) ) Frequency(tp.n); if ( (testVector[0] == 1) || (testVector[TEST_BLOCK_FREQUENCY] == 1) ) BlockFrequency(tp.blockFrequencyBlockLength, tp.n); if ( (testVector[0] == 1) || (testVector[TEST_CUSUM] == 1) ) CumulativeSums(tp.n); if ( (testVector[0] == 1) || (testVector[TEST_RUNS] == 1) ) Runs(tp.n); if ( (testVector[0] == 1) || (testVector[TEST_LONGEST_RUN] == 1) ) LongestRunOfOnes(tp.n); if ( (testVector[0] == 1) || (testVector[TEST_RANK] == 1) ) Rank(tp.n); if ( (testVector[0] == 1) || (testVector[TEST_FFT] == 1) ) DiscreteFourierTransform(tp.n); if ( (testVector[0] == 1) || (testVector[TEST_NONPERIODIC] == 1) ) NonOverlappingTemplateMatchings(tp.nonOverlappingTemplateBlockLength, tp.n); if ( (testVector[0] == 1) || (testVector[TEST_OVERLAPPING] == 1) ) OverlappingTemplateMatchings(tp.overlappingTemplateBlockLength, tp.n); if ( (testVector[0] == 1) || (testVector[TEST_UNIVERSAL] == 1) ) Universal(tp.n); if ( (testVector[0] == 1) || (testVector[TEST_APEN] == 1) ) ApproximateEntropy(tp.approximateEntropyBlockLength, tp.n); if ( (testVector[0] == 1) || (testVector[TEST_RND_EXCURSION] == 1) ) RandomExcursions(tp.n); if ( (testVector[0] == 1) || (testVector[TEST_RND_EXCURSION_VAR] == 1) ) RandomExcursionsVariant(tp.n); if ( (testVector[0] == 1) || (testVector[TEST_SERIAL] == 1) ) Serial(tp.serialBlockLength,tp.n); if ( (testVector[0] == 1) || (testVector[TEST_LINEARCOMPLEXITY] == 1) ) LinearComplexity(tp.linearComplexitySequenceLength, tp.n); if ( (testVector[0] == 1) || (testVector[TEST_FFT80] == 1) ) DiscreteFourierTransform80(tp.n); }