Anonymous user
Unbias a random generator: Difference between revisions
m
→{{header|REXX}}: simplified program, added/changed comments and whitespace, used template for the OUTPUTs.
m (→{{header|Nim}}) |
m (→{{header|REXX}}: simplified program, added/changed comments and whitespace, used template for the OUTPUTs.) |
||
Line 1,521:
=={{header|REXX}}==
<lang rexx>/*REXX program generates unbiased random numbers and displays the results to terminal.*/
parse arg # R seed . /*
if #=='' | #=="," then #=1000 /*#
if R=='' | R=="," then R=6 /*R
if datatype(seed, 'W') then call random ,,seed /*
say
▲say pad c('N',5) c(@b) c(@b'%') c(@ub) c(@ub"%") c('samples') /*six column header.*/
dash=
do N=3 to R;
do j=1 for #; b=b +
say
end /*N*/
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
pct:
randN:
unbiased:
<pre>
──N── ───biased─── ──biased%─── ──unbiased── ─unbiased%── ──samples───
Line 1,548 ⟶ 1,547:
6 178 17.80% 488 48.80% 1000
</pre>
<pre>
──N── ───biased─── ──biased%─── ──unbiased── ─unbiased%── ──samples───
Line 1,556 ⟶ 1,555:
6 1644 16.44% 4982 49.82% 10000
</pre>
<pre>
──N── ───biased─── ──biased%─── ──unbiased── ─unbiased%── ──samples───
|