home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / Samples / C-SSP.ARJ / STCHI2.C < prev    next >
Encoding:
Text File  |  1984-07-24  |  450 b   |  22 lines

  1.       stchi2 (a,b,c,d,chi2)
  2.  
  3.       /*this subroutine computes chi square for 2 by 2 tables*/
  4.       /*with yates correction for continuity.*/
  5.  
  6.       float a,b,c,d,*chi2;
  7.  
  8.      {
  9.       float r1,r2,c1,c2,s,e,f,g;
  10.       extern double fabs();
  11.  
  12.       r1 = a + b;
  13.       r2 = c + d;
  14.       c1 = a + c;
  15.       c2 = b + d;
  16.       s = r1 + r2;
  17.       e = fabs(a*d-b*c);
  18.       f = e-0.5*s;
  19.       g = s*f*f;
  20.       *chi2 = g/(r1*r2*c1*c2);
  21.     }
  22.