Category : C Source Code
Archive   : RECIPEX.ZIP
Filename : CNTAB1.C
#define TINY 1.0e-30
void cntab1(nn,ni,nj,chisq,df,prob,cramrv,ccc)
int **nn,ni,nj;
float *chisq,*df,*prob,*cramrv,*ccc;
{
int nnj,nni,j,i,minij;
float sum=0.0,expctd,*sumi,*sumj,temp,gammq(),*vector();
void free_vector();
sumi=vector(1,ni);
sumj=vector(1,nj);
nni=ni;
nnj=nj;
for (i=1;i<=ni;i++) {
sumi[i]=0.0;
for (j=1;j<=nj;j++) {
sumi[i] += nn[i][j];
sum += nn[i][j];
}
if (sumi[i] == 0.0) --nni;
}
for (j=1;j<=nj;j++) {
sumj[j]=0.0;
for (i=1;i<=ni;i++) sumj[j] += nn[i][j];
if (sumj[j] == 0.0) --nnj;
}
*df=nni*nnj-nni-nnj+1;
*chisq=0.0;
for (i=1;i<=ni;i++) {
for (j=1;j<=nj;j++) {
expctd=sumj[j]*sumi[i]/sum;
temp=nn[i][j]-expctd;
*chisq += temp*temp/(expctd+TINY);
}
}
*prob=gammq(0.5*(*df),0.5*(*chisq));
minij = nni < nnj ? nni-1 : nnj-1;
*cramrv=sqrt(*chisq/(sum*minij));
*ccc=sqrt(*chisq/(*chisq+sum));
free_vector(sumj,1,nj);
free_vector(sumi,1,ni);
}
#undef TINY
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/