Data update
This commit is contained in:
parent
ed705008a8
commit
0df55f9f24
2196 changed files with 32999 additions and 3075 deletions
24
Task/Probabilistic-choice/EasyLang/probabilistic-choice.easy
Normal file
24
Task/Probabilistic-choice/EasyLang/probabilistic-choice.easy
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
name$[] = [ "aleph " "beth " "gimel " "daleth" "he " "waw " "zayin " "heth " ]
|
||||
probs[] = [ 1 / 5 1 / 6 1 / 7 1 / 8 1 / 9 1 / 10 1 / 11 0 ]
|
||||
for i = 1 to 7
|
||||
cum += probs[i]
|
||||
cum[] &= cum
|
||||
.
|
||||
cum[] &= 1
|
||||
probs[8] = 1 - cum[7]
|
||||
len act[] 8
|
||||
n = 1000000
|
||||
for i to n
|
||||
h = randomf
|
||||
j = 1
|
||||
while h > cum[j]
|
||||
j += 1
|
||||
.
|
||||
act[j] += 1
|
||||
.
|
||||
print "Name Ratio Expected"
|
||||
print "---------------------"
|
||||
numfmt 4 6
|
||||
for i to 8
|
||||
print name$[i] & " " & act[i] / n & " " & probs[i]
|
||||
.
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import "random" for Random
|
||||
import "/fmt" for Fmt
|
||||
import "./fmt" for Fmt
|
||||
|
||||
var letters = ["aleph", "beth", "gimel", "daleth", "he", "waw", "zayin", "heth"]
|
||||
var actual = [0] * 8
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue