Monte Carlo methods: Difference between revisions

m
→‎{{header|REXX}}: changed spelling of a variable.
m (→‎{{header|REXX}}: optimized the inner DO loop.)
m (→‎{{header|REXX}}: changed spelling of a variable.)
Line 1,931:
limit=10000 /*REXX random generates only integers. */
limitSq=limit**2 /*··· so, instead of one, use limit**2.*/
accuraccuracy=0 /*accuracy of Monte Carlo pi (so far).*/
!=0; @reps= 'repetitions: Monte Carlo pi is' /*pi decimal digit accuracy (so far).*/
say /*a blank line, just for the eyeballs.*/
Line 1,940:
reps=chunk * j /*calculate the number of repetitions. */
_=compare(4*! / reps, pi) /*compare apples and ··· crabapples. */
if _<=accuraccuracy then iterate /*Not better accuracy? Keep truckin'. */
say right(comma(reps), 20) @reps 'accurate to' _-1 "places." /*─1 ≡ dec. point*/
accuraccuracy=_ /*use this accuracy for next baseline. */
end /*j*/
exit /*stick a fork in it, we're all done. */