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