home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 174 / 174.d81 / astro-odds (.txt) < prev    next >
Commodore BASIC  |  2022-08-26  |  3KB  |  131 lines

  1. 5 poke55,.:poke56,56:clr
  2. 10 dv=peek(186):ifdv<8thendv=8
  3. 15 poke53280,0:poke53281,0:print"[147]"
  4. 16 poke53371,0
  5. 30 ad=49152
  6. 35 sysad:sysad+12
  7. 40 mp=.1
  8. 42 po$="[150][193][211][212][210][207][206][207][205][201][195][193][204]  [208][210][207][194][193][194][201][204][201][212][217]  &  [207][196][196][211]"
  9. 44 bs$="[150]_[157]_[157]_[157]_[157]_[157]_[157]_[157]_[157]_[157]_[157]_[157]_[157]_[157]_[157]_[157]_[157]_[157]_[157]_[157]_[157]_[157]_"
  10. 45 a1$=" -[208]robability and [207]dds are- "
  11. 48 tq=ti
  12. 50 a2$="[153][197]vt[159] [204]ess [212]han [158] [197]xactly   [150] [199]reater [212]han"
  13. 52 poke53272,31
  14. 55 bx$="[154]_[157]_[157]_[157]_[157]_[157]_[157]_[157]_"
  15. 57 gosub500
  16. 60 print"[147]":poke53280,.:poke53281,.:sysad+9,2
  17. 61 printtab(2)""po$
  18. 62 poke214,4:print:printtab(3)"[154]^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
  19. 63 printtab(3)bx$""tab(34)bx$
  20. 64 printtab(3)"[154]^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
  21. 65 rem get input and print header
  22. 75 print"":printtab(5)"[158][197]vent rate [153]([204]ambda) ";:l9%=8:gosub355:l=q9
  23. 80 printtab(5)"[158][201]nterval [153]([212]ime) ";:l9%=5:gosub355:t=q9
  24. 85 ifexp(-l*t)>0then97
  25. 90 print:printtab(5)"[158] [211]orry - out of [210]ange! "
  26. 91 tq=ti
  27. 92 ifti<tq+200then92
  28. 95 goto60
  29. 97 print:printtab(7)"[155][201]s this correct? (y[155]/n[155])":poke198,.
  30. 98 gethc$:ifhc$<>"y"andhc$<>"n"then98
  31. 100 print"[147]":sysad+9,4:gosub400
  32. 104 printtab(5)a1$
  33. 105 print""a2$
  34. 115 :
  35. 120 rem initialize loop variables
  36. 125 n=0
  37. 130 mu=l*t
  38. 135 pf=0:rem prob of fewer than n
  39. 140 pe=100*exp(-mu): rem prob of exactly n
  40. 145 :
  41. 150 rem comput probabilities (and odds)
  42. 155 :
  43. 160 pg=100-pf-pe: rem prob more than n
  44. 165 ifpg>99.999then190
  45. 170 sysad+9,5:print"[153]"n;
  46. 175 p=pf:c=1:gosub220
  47. 180 p=pe:c=13:gosub220
  48. 185 p=pg:c=25:gosub220:print
  49. 190 n=n+1:ifn=18orn=36orn=54orn=72thengosub410
  50. 195 pf=pf+pe
  51. 200 pe=pe*mu/n
  52. 205 ifpg>=mpthen160
  53. 210 gosub3000
  54. 212 goto40
  55. 215 :
  56. 220 rem print prob (and odds)
  57. 225 printtab(c);
  58. 230 ifp>.001andp<99.999 then240
  59. 235 printtab(5)"[156]- n/a -";:goto275
  60. 240 print""int(p);"[157]%";
  61. 245 ifp>50 then265
  62. 250 print"[154] 1[150]:";
  63. 255 v=((100-p)/p)
  64. 260 gosub285:goto275
  65. 265 v=(p/(100-p))
  66. 270 gosub285:print"[150]:[154]1";
  67. 275 return
  68. 280 :
  69. 285 rem format odds
  70. 290 ifv>=9.5then305
  71. 295 print"[155]"int(v);
  72. 300 goto310
  73. 305 print"[155]"int(v+.5);
  74. 310 return
  75. 355 q9$="":poke198,.
  76. 360 geta$
  77. 365 poke646,rnd(1)*15+1:print"*[157]";:ifa$=""then360
  78. 370 ifa$=chr$(13)thenprint" ":q9=val(q9$):return
  79. 375 if(a$=chr$(20)andlen(q9$))thenq9$=left$(q9$,len(q9$)-1):goto397
  80. 380 iflen(q9$)>=l9%thensysad+9,1:goto360
  81. 385 if(a$>="0"anda$<="9")ora$="."ora$="-"ora$="+"then390
  82. 387 goto360
  83. 390 q9$=q9$+a$
  84. 395 print""a$;:sysad+9,3:goto360
  85. 397 print" [157][157] [157]";:goto360
  86. 400 fori=217to242:pokei,peek(i)or128:next:return
  87. 410 print:printtab(8)"[150][193]ny key to continue.":poke198,.
  88. 415 gethc$:ifhc$=""then415
  89. 420 print"[147]";tab(5)a1$
  90. 450 print""a2$:return
  91. 500 print"[147][153][214]iew [193]stronomical [197]vent [195]hart? (y[153]/n[153])":poke198,.
  92. 502 sysad+9,1
  93. 505 geta$:ifa$<>"y"anda$<>"n"then505
  94. 510 ifa$="n"then60
  95. 515 print"[147][150]^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
  96. 520 printbs$;""tab(38)bs$
  97. 525 print"[150]^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^":sysad+9,2
  98. 530 print"":printtab(6)"[156] [193][211][212][210][207][206][207][205][201][195][193][204] [197][214][197][206][212] [195][200][193][210][212] "
  99. 535 printtab(2)"[158][211]poradic [205]eteors      [158]  6 to 10/hour"
  100. 538 printtab(2)"[159]([211]ingle observer with dark skies) "
  101. 540 printtab(2)"[158][198]ireballs               .005/hour"
  102. 545 printtab(2)"[208]erseid [205]eteors          60/hour  "
  103. 548 printtab(2)"[159](seen near its peak)"
  104. 550 printtab(2)"[158][208]erseid [208]hoto [159](400 [201][211][207] [158] .6/hour"
  105. 552 printtab(2)"[159]50 mm f/1.8 lens)"
  106. 555 printtab(2)"[158][199]reat [195]omet [159](mag. 1    [158] .1/year"
  107. 558 printtab(2)"[159]or brighter)"
  108. 560 printtab(2)"[158][194]right [206]ova [159](mag. 3    [158] .06/year"
  109. 562 printtab(2)"[159]or brighter)"
  110. 565 printtab(2)"[158][211][213][208][197][210][206][207][214][193]               .004/year"
  111. 568 printtab(2)"[159](mag. 3 or brighter)"
  112. 570 printtab(2)"[158][195]rater forming   .0000001/century"
  113. 575 printtab(2)"[158]impact [159](on earth per square mile)"
  114. 580 printtab(2)"[158][195]rater forming impact   6/century"
  115. 585 printtab(2)"[159](anywhere on land mass)"
  116. 590 printtab(2)"[158][197]xtinction causing   .000003/century"
  117. 592 printtab(2)"impacts [159](by asteriod or comet)"
  118. 600 print:printtab(7)"[193]ny key for [215]ork [211]creen":poke198,.
  119. 605 geta$:ifa$=""then605
  120. 610 goto60
  121. 3000 print:printtab(8)"[159](1[159]) [212]ry another one
  122. 3010 [153][163]8)"open(2open) (NULL)o (NULL)(NULL)right$(NULL)val(NULL)(NULL)val (NULL)enu
  123. 3020 poke198,0
  124. 3030 geta$:ifa$<"1"ora$>"2"then3030
  125. 3040 ifa$="1"thenreturn
  126. 3050 sysad+15
  127. 3060 print"[147][144]load"chr$(34)"b.universe iii"chr$(34)","dv
  128. 3070 print"run28"
  129. 3080 poke631,13:poke632,13:poke198,2:end
  130. 10000 d=peek(186):n$="0:astro-odds":open15,d,15,"s"+n$:close15:saven$,d:end
  131.