tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
19
Task/Probabilistic-choice/BBC-BASIC/probabilistic-choice.bbc
Normal file
19
Task/Probabilistic-choice/BBC-BASIC/probabilistic-choice.bbc
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
DIM item$(7), prob(7), cnt%(7)
|
||||
item$() = "aleph","beth","gimel","daleth","he","waw","zayin","heth"
|
||||
prob() = 1/5.0, 1/6.0, 1/7.0, 1/8.0, 1/9.0, 1/10.0, 1/11.0, 1759/27720
|
||||
IF ABS(SUM(prob())-1) > 1E-6 ERROR 100, "Probabilities don't sum to 1"
|
||||
|
||||
FOR trial% = 1 TO 1E6
|
||||
r = RND(1)
|
||||
p = 0
|
||||
FOR i% = 0 TO DIM(prob(),1)
|
||||
p += prob(i%)
|
||||
IF r < p cnt%(i%) += 1 : EXIT FOR
|
||||
NEXT
|
||||
NEXT
|
||||
|
||||
@% = &2060A
|
||||
PRINT "Item actual theoretical"
|
||||
FOR i% = 0 TO DIM(item$(),1)
|
||||
PRINT item$(i%), cnt%(i%)/1E6, prob(i%)
|
||||
NEXT
|
||||
Loading…
Add table
Add a link
Reference in a new issue