home *** CD-ROM | disk | FTP | other *** search
/ Current Shareware 1994 January / SHAR194.ISO / engineer / ksprob21.zip / KSMISC.EXE / KSWSRCDF.PAS < prev    next >
Pascal/Delphi Source File  |  1993-05-20  |  1KB  |  49 lines

  1. program wsrcdf;
  2.  
  3. { for given n < 30, wsr computes the cumulative distribution function
  4.   of the sum of positive ranks for the Wilcoxon signed rank test}
  5.  
  6. uses dos,crt,ksutils;
  7.  
  8. var
  9.   i,j,n,maxsum : word;
  10.   kount : array[0..465] of longint;
  11.   cdf,tot,cumsum : real;
  12.   ofil : text;
  13.   ofiln : pathstr;
  14.  
  15. begin
  16.   clrscr;
  17.   gotoxy(1,1); write('n = ',' ':10);
  18.   gotoxy(6,1); readln(n);
  19.   if n > 30 then exit;
  20.   gotoxy(1,2); write('outfile: ');
  21.   ofiln := '';
  22.   gotoxy(10,2); readln(ofiln);
  23.   assign(ofil,ofiln);
  24.   if isfile(ofiln) then append(ofil) else rewrite(ofil);
  25.   writeln(ofil,'; ',n);
  26.   close(ofil);
  27.   maxsum := 1;
  28.   kount[0] := 1;
  29.   kount[1] := 1;
  30.   for i := 2 to 465 do kount[i] := 0;
  31.   for i := 2 to n do
  32.   begin
  33.     inc(maxsum,i);
  34.     for j := maxsum downto i do kount[j] := kount[j] + kount[j - i]
  35.   end;
  36.   tot := 0.0;
  37.   for i := 0 to maxsum do tot := tot + kount[i];
  38.   cumsum := 0.0;
  39.   assign(ofil,ofiln);
  40.   append(ofil);
  41.   for i := 0 to maxsum do
  42.   begin
  43.     cumsum := cumsum + kount[i];
  44.     cdf := cumsum / tot;
  45.     writeln(ofil,i,' ',cdf:10:6)
  46.   end;
  47.   close(ofil)
  48. end.
  49.