home *** CD-ROM | disk | FTP | other *** search
/ Play and Learn 2 / 19941.ZIP / 19941 / EDUCMATH / STATS / POISSON.BAS (.txt) < prev    next >
Encoding:
GW-BASIC  |  1994-02-04  |  1.7 KB  |  28 lines

  1. 1  '                POISSON DISTRIBUTION (one-tailed)
  2. 2  '               Copyright Tracy L. Gustafson, M.D.
  3. 3  '              Round Rock, Texas. Version 3.2, 1985
  4. 4  ON ERROR GOTO 5000:CHAIN MERGE "EPIMRG",5
  5. 22  DATA "POISSON PROBABILITY DISTRIBUTION",22,34
  6. 30  PRINT " The Poisson distribution is a one-tailed exact test that applies specifically ":PRINT " when the number of SUCCESSES can be counted but the number of FAILURES cannot."
  7. 35  PRINT TAB(8);"It can also be used to approximate the binomial distribution":PRINT TAB(4);"when the number of trials is > 100 and the the population rate is < 5% ."
  8. 40  LOCATE 11,22:PRINT "Enter the number of cases OBSERVED:"
  9. 45  AR=11:AC=60:GOSUB 4800:I=VAL(IP$):IF INT(I)=I THEN XO=I ELSE BEEP:LOCATE 25,21:PRINT "Observed number must be an integer.";:GOTO 45
  10. 50  LOCATE 13,22:PRINT "Enter the number of cases EXPECTED:"
  11. 55  PRINT TAB(29);"(may be a fraction)":PRINT TAB(20);"(e.g. population rate * time interval)":AR=13:AC=60:GOSUB 4800:E=VAL(IP$)
  12. 60  COLOR 23:LOCATE 17,28:PRINT "CALCULATING PROBABILITY"
  13. 65  AF=0:YO=XO:CE=0:IF E<YO THEN YO=YO-1:AF=1
  14. 70  IF YO=0 THEN SF=1 ELSE SF=E+1
  15. 75  F=E:FOR Z=2 TO YO:F=F*E/Z:IF F>1E+22 THEN F=F*0:SF=SF* 0:CE=CE+1
  16. 80  IF F>=0 THEN SF=SF+F:NEXT Z
  17. 85  SL=LOG(SF)-E+CE*50:IF SL>80 THEN P=0 ELSE P=EXP(SL)
  18. 90  IF AF=1 THEN P=1-P
  19. 95  PLAY "MS O3 L64 G O2 GE L9 E"
  20. 100  COLOR CLR2,CLR1:LOCATE 17,1:PRINT TAB(8);"The probability of observing ";XO;" or ";
  21. 105  IF AF=1 THEN PRINT "more cases "; ELSE PRINT "fewer cases ";
  22. 110  IF P<9.99E-07 THEN PRINT "< 10 (-6)"; ELSE IF P>0.95 THEN PRINT "> .95"; ELSE PRINT "= ";P;
  23. 115  PRINT TAB(80):COLOR CLR1,CLR2:LOCATE 25,6:INPUT;"Do you want to perform another Poisson distribution calculation?  ",A$:IF A$="y" OR A$="Y" THEN 20
  24. 120  GOTO 3000
  25. 5000  BEEP:IF ERR<>53 AND ERR<>71 THEN 5010 ELSE LOCATE 2,10:PRINT "Please place EPISTAT in drive A: (or other default).":PRINT TAB(25);"Press any key to continue:"
  26. 5005  A$=INKEY$:IF A$="" THEN 5005 ELSE RESUME
  27. 5010  ON ERROR GOTO 0:END
  28.