// // main.cpp // randomph // // Created by Paul Beale on 12/4/14. // Copyright (c) 2014 Paul Beale. All rights reserved. // // Test randomph() using a single process #include "randomph.h" #include #include #include #include #include using namespace std; //determine the one-sided p-value from the chi square test for a uniform distribution with a large number of degrees of freedom double ChiSquareLargeNPValue(int* histogram,int n) { double degreesoffreedom=n-1; double average=0.0,chisqr=0.0,pvalue,sigma; for (int i=0;i ip) countpvalues[ip]++; pvalue=ChiSquareLargeNPValue(hist2d,1048576); log10pvalue = log10(pvalue); countpvalues[0]++; for (int ip=1;ip<=8;ip++) if (-log10pvalue > ip) countpvalues[ip]++; pvalue = ChiSquareLargeNPValue(hist3d,1000000); log10pvalue = log10(pvalue); countpvalues[0]++; for (int ip=1;ip<=8;ip++) if (-log10pvalue > ip) countpvalues[ip]++; pvalue = ChiSquareLargeNPValue(hist4d,1048576); log10pvalue = log10(pvalue); countpvalues[0]++; for (int ip=1;ip<=8;ip++) if (-log10pvalue > ip) countpvalues[ip]++; pvalue = ChiSquareLargeNPValue(hist5d,1048576); log10pvalue = log10(pvalue); countpvalues[0]++; for (int ip=1;ip<=8;ip++) if (-log10pvalue > ip) countpvalues[ip]++; } getparameters_randomph(integerparameters); unsigned long mf, sf, cf, q, r; q=(5*ntests*nrounds)/(p0-1); r=(5*ntests*nrounds)%(p0-1); sf=s0; mf=(p0*(p0-1)/2)%n0; mf= (q*mf)%n0; mf=(mf+m0)%n0; // m_{q (p-1)} = (m_0 + q p(p-1)/2 ) mod n // step forward r steps for (int j=1;j<=r;j++) { sf=(a0*sf)%p0; mf=(mf+sf)%n0; } cf=powermod(mf,e0,n0); cout << "final state of the generator: m, s, c, n, e, p, a" << endl; for (int j=0;j<7;j++) cout << integerparameters[j] << " "; cout << endl; cout << "expected final state of the generator: m, s, c, n, e, p, a" <