52 lines
1.2 KiB
Plaintext
52 lines
1.2 KiB
Plaintext
dim letters$ = {"aleph", "beth", "gimel", "daleth", "he", "waw", "zayin", "heth"}
|
|
dim actual(8) fill 0 ## all zero by default
|
|
dim probs = {1/5.0, 1/6.0, 1/7.0, 1/8.0, 1/9.0, 1/10.0, 1/11.0, 0}
|
|
dim cumProbs(8)
|
|
|
|
cumProbs[0] = probs[0]
|
|
for i = 1 to 6
|
|
cumProbs[i] = cumProbs[i - 1] + probs[i]
|
|
next i
|
|
cumProbs[7] = 1.0
|
|
probs[7] = 1.0 - cumProbs[6]
|
|
|
|
n = 1000000
|
|
sum = 0.0
|
|
|
|
for i = 1 to n
|
|
rnd = rand ## random number where 0 <= rand < 1
|
|
begin case
|
|
case rnd <= cumProbs[0]
|
|
actual[0] += 1
|
|
case rnd <= cumProbs[1]
|
|
actual[1] += 1
|
|
case rnd <= cumProbs[2]
|
|
actual[2] += 1
|
|
case rnd <= cumProbs[3]
|
|
actual[3] += 1
|
|
case rnd <= cumProbs[4]
|
|
actual[4] += 1
|
|
case rnd <= cumProbs[5]
|
|
actual[5] += 1
|
|
case rnd <= cumProbs[6]
|
|
actual[6] += 1
|
|
else
|
|
actual[7] += 1
|
|
end case
|
|
next i
|
|
|
|
sumActual = 0
|
|
|
|
print "Letter", " Actual", "Expected"
|
|
print "------", "--------", "--------"
|
|
for i = 0 to 7
|
|
print ljust(letters$[i],14," ");
|
|
print ljust(actual[i]/n,8,"0"); " ";
|
|
sumActual += actual[i]/n
|
|
print ljust(probs[i],8,"0")
|
|
next i
|
|
|
|
print " ", "--------", "--------"
|
|
print " ", ljust(sumActual,8,"0"), "1.000000"
|
|
end
|