ChipMaster's bwBASIC This also includes history going back to v2.10. *WARN* some binary files might have been corrupted by CRLF.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

81 lines
2.2 KiB

  1. 10 ' Poisson Distribution
  2. 20 ' by Mark Gingrich
  3. 30 MP=.1
  4. 40 A1$="Probability (and odds) of..."
  5. 50 A2$="# events fewer than"
  6. 60 A3$="exactly greater than"
  7. 70 A4$=" (n) n events "
  8. 80 A5$="n events n events "
  9. 90 A6$ = "-------------------------"
  10. 100 A7$=" "
  11. 110 '
  12. 120 ' Get input and print header
  13. 130 PRINT:PRINT
  14. 140 INPUT "Event rate (lambda)";L
  15. 150 INPUT "Interval (t)";T
  16. 160 IF EXP(-L*T)>0 THEN 190
  17. 170 PRINT "Sorry, out of range"
  18. 180 GOTO 420
  19. 190 PRINT:PRINT SPC(29); A1$
  20. 200 PRINT:PRINT A2$;A7$;A3$
  21. 210 PRINT A4$;A7$;A5$
  22. 220 PRINT A6$;A6$;A6$
  23. 230 '
  24. 240 ' Initialize loop variables
  25. 250 N=0
  26. 260 MU=L*T
  27. 270 PF=0: ' Prob of fewer than n
  28. 280 PE=100*EXP(-MU): ' Prob of exactly n
  29. 290 '
  30. 300 ' Compute Probabilities (and odds)
  31. 310 '
  32. 320 PG=100-PF-PE: ' Prob of greater than n
  33. 330 IF PG>99.999 THEN 380
  34. 340 PRINT USING " ##"; N;
  35. 350 P=PF: C=13: GOSUB 440
  36. 360 P=PE: C=34: GOSUB 440
  37. 370 P=PG: C=55: GOSUB 440: PRINT
  38. 380 N=N+1
  39. 390 PF=PF+PE
  40. 400 PE=PE*MU/N
  41. 410 IF PG>=MP THEN 320
  42. 420 END
  43. 430 '
  44. 440 ' Print probability (and odds)
  45. 450 PRINT TAB(C);
  46. 460 IF P>.001 AND P<99.999 THEN 480
  47. 470 PRINT " - - -";: GOTO 560
  48. 480 PRINT USING "###.#% (";P;
  49. 490 IF P>50 THEN 530
  50. 500 PRINT " 1 :";
  51. 510 V=((100-P)/P)
  52. 520 GOSUB 580: GOTO 550
  53. 530 V=(P/(100-P))
  54. 540 GOSUB 580: PRINT ": 1 ";
  55. 550 PRINT ")";
  56. 560 RETURN
  57. 570 '
  58. 580 ' Format odds
  59. 590 IF V>=9.5 THEN 620
  60. 600 PRINT USING " #.# ";V;
  61. 610 GOTO 630
  62. 620 PRINT INT(V+.5);
  63. 630 RETURN
  64. 640 '
  65. 650 ' Poisson statistics are used to
  66. 660 ' predict how likely it is for bunches or
  67. 670 ' gaps to occur in a stream of random
  68. 680 ' events, such as appearances of bright
  69. 690 ' comets, novae, cosmic rays, meteors, or
  70. 700 ' even the way stars are sprinkled across
  71. 710 ' a section of sky. By comparing this
  72. 720 ' program's output to actual
  73. 730 ' observations, it is often possible to
  74. 740 ' decide whether the events of a given
  75. 750 ' class do, in fact, have a random
  76. 760 ' distribution in time or space. Mark
  77. 770 ' Gingrich explores this subject in his
  78. 780 ' article, "Great Comets, Novae, and Lady
  79. 790 ' Luck," in Sky & Telescope for June
  80. 800 ' 1995, pages 86-89.