#include "header.h" static real chi_fit; static int dgf; int ucmpr(const void *u1, const void *u2); /*compute the statistic of goodness of fit to a Poisson distribution*/ real P_fit(real lambda, counter *obs, int no_obs) { counter *f, dim=no_obs/5; register int i=-1; register counter j, k=0; real rest=no_obs, *Ef; f=(counter*)calloc(dim, sizeof(counter)); Ef=(real*)calloc(dim, sizeof(real)); qsort(obs, no_obs, sizeof(counter), ucmpr); for(j=0; j=2^18, for comparing the results |"); puts("\t|to the Poisson distribution with that mean. This test uses |"); puts("\t|n=2^24 and m=2^10, so that the underlying distribution for j |"); puts("\t|is taken to be Poisson with lambda=2^30/(2^26)=16. A sample |"); puts("\t|of 200 j''s is taken, and a chi-square goodness of fit test |"); puts("\t|provides a p value. The first test uses bits 1-24 (counting |"); puts("\t|from the left) from integers in the specified file. Then the|"); puts("\t|file is closed and reopened, then bits 2-25 of the same inte-|"); puts("\t|gers are used to provide birthdays, and so on to bits 9-32. |"); puts("\t|Each set of bits provides a p-value, and the nine p-values |"); puts("\t|provide a sample for a KSTEST. |"); puts("\t|------------------------------------------------------------ |\n"); printf("\t\tRESULTS OF BIRTHDAY SPACINGS TEST FOR %s\n", filename); printf("\t(no_bdays=%d, no_days/yr=2^%d,",no_bday, no_bits); printf(" lambda=%.2f, sample size=%d)\n\n", lambda, no_obs); printf("\tBits used\tmean\t\tchisqr\t\tp-value\n"); obs=(counter*)malloc(no_obs*sizeof(counter)); p=(real*)malloc((32-no_bits+1)*sizeof(real)); bdspace=(uniform*)malloc(no_bday*sizeof(uniform)); #define GETDAY ( (uni(filename) >> rt) & mask ) for(rt=32-no_bits; rt>=0; --rt){ sum=0; for(k=0; k=1; --i){ bdspace[i]-=bdspace[i-1]; } qsort(bdspace, no_bday, sizeof(uniform), ucmpr); no_dup=0; for(i=1; i