Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
28
Task/Probabilistic-choice/Phix/probabilistic-choice.phix
Normal file
28
Task/Probabilistic-choice/Phix/probabilistic-choice.phix
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
constant {names, probs} = columnize({{"aleph", 1/5},
|
||||
{"beth", 1/6},
|
||||
{"gimel", 1/7},
|
||||
{"daleth", 1/8},
|
||||
{"he", 1/9},
|
||||
{"waw", 1/10},
|
||||
{"zayin", 1/11},
|
||||
{"heth", 1759/27720}})
|
||||
|
||||
sequence results = repeat(0,length(names))
|
||||
|
||||
atom r
|
||||
constant lim = 1000000
|
||||
for j=1 to lim do
|
||||
r = rnd()
|
||||
for i=1 to length(probs) do
|
||||
r -= probs[i]
|
||||
if r<=0 then
|
||||
results[i]+=1
|
||||
exit
|
||||
end if
|
||||
end for
|
||||
end for
|
||||
|
||||
printf(1," Name Actual Expected\n")
|
||||
for i=1 to length(probs) do
|
||||
printf(1,"%6s %8.6f %8.6f\n",{names[i],results[i]/lim,probs[i]})
|
||||
end for
|
||||
Loading…
Add table
Add a link
Reference in a new issue