1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
#include <stdio.h>
#include "tests.h"
double mytest (long n);
main(int argc, char *argv[])
{
long ntests, n, i;
double *V, result;
ntests = init_tests(argc,argv);
V = (double *) mymalloc(NTESTS*sizeof(double));
n = atol(argv[N_STREAM_PARAM+1]);
for(i=0; i<ntests; i++)
{
V[i] = mytest(n); /* test and find chisquare value */
next_stream();
}
#if defined(SPRNG_MPI)
/* Get chisquare values from other processes in order to perform the
Kolmogorov-Smirnov test */
getKSdata(V,NTESTS);
#endif
if(proc_rank == 0) /* Perform KS test on data from individual tests */
{
set_d_of_f(1);
result = KS(V,NTESTS,chiF);
result = KSpercent(result,NTESTS);
printf("\t KS %% = %.2f\n\n", result*100.0);
}
free(V);
}
double mytest(long n)
{
double temp;
long actual[2]={0,0};
double expected[2]={0.5, 0.5};
long i;
int temp2;
for(i=0; i<n; i++)
{
temp = get_rn();
if(temp > 0.5)
actual[0]++;
else
actual[1]++;
}
return chisquare(actual,expected,n,2,&temp2);
}
|