Probabilistic choice: Difference between revisions
Content added Content deleted
Drkameleon (talk | contribs) (Added Arturo implementation) |
|||
Line 2,402: | Line 2,402: | ||
heth 0.063442 0.063456 |
heth 0.063442 0.063456 |
||
</pre> |
</pre> |
||
=={{header|Phixmonti}}== |
|||
<lang Phixmonti>/# Rosetta Code problem: http://rosettacode.org/wiki/Probabilistic_choice |
|||
by Galileo, 05/2022 #/ |
|||
include ..\Utilitys.pmt |
|||
( ( "aleph" 0.200000 0 ) ( "beth" 0.166667 0 ) ( "gimel" 0.142857 0 ) ( "daleth" 0.125000 0 ) |
|||
( "he" 0.111111 0 ) ( "waw" 0.100000 0 ) ( "zayin" 0.090909 0 ) ( "heth" 0.063456 0 ) ) |
|||
len 1 swap 2 tolist var lprob |
|||
1000000 var trial |
|||
trial for drop |
|||
rand >ps |
|||
0 >ps |
|||
lprob for var i |
|||
( i 2 ) sget ps> + |
|||
tps swap dup >ps < if |
|||
( i 3 ) sget 1 + ( i 3 ) sset |
|||
exitfor |
|||
endif |
|||
endfor |
|||
ps> ps> drop drop |
|||
endfor |
|||
( "item" "\t" "actual" "\t\t" "theoretical" ) lprint nl nl |
|||
lprob for drop |
|||
pop swap |
|||
1 get "\t" rot 3 get trial / "\t" rot 2 get nip "\n" 6 tolist lprint |
|||
endfor</lang> |
|||
{{out}} |
|||
<pre>item actual theoretical |
|||
aleph 0.200018 0.2 |
|||
beth 0.166987 0.166667 |
|||
gimel 0.142654 0.142857 |
|||
daleth 0.125217 0.125 |
|||
he 0.111668 0.111111 |
|||
waw 0.099827 0.1 |
|||
zayin 0.090311 0.090909 |
|||
heth 0.063318 0.063456 |
|||
=== Press any key to exit ===</pre> |
|||
=={{header|PicoLisp}}== |
=={{header|PicoLisp}}== |