Monte Carlo methods: Difference between revisions

m
m (→‎{{header|Wren}}: Minor tidy)
 
(3 intermediate revisions by 2 users not shown)
Line 1,733:
piMC 10^i.7
4 2.8 3.24 3.168 3.1432 3.14256 3.14014</syntaxhighlight>
 
'''Alternative Tacit Solution:'''
<syntaxhighlight lang="j">pimct=. (4 * +/ % #)@:(1 >: |)@:(? j. ?)@:($&0)"0
(,. pimct) 10 ^ 3 + i.6
1000 3.168
10000 3.122
100000 3.13596
1e6 3.1428
1e7 3.14158
1e8 3.14154</syntaxhighlight>
 
=={{header|Java}}==
Line 2,821 ⟶ 2,832:
 
=={{header|RPL}}==
≪ 0 1 3 PICK '''START'''
RAND SQ RAND SQ '''IF''' + 1 <3 '''THEN''' 1 +PICK '''END NEXTSTART'''
RAND SQ RAND SQ + 1 < +
SWAP / 4 *
'''NEXT'MCARL'''' STO
SWAP / 4 *
≫ '<span style="color:blue">MCARL</span>' STO
 
100 '''<span style="color:blue">MCARL'''</span>
1000 <span style="color:blue">MCARL</span>
10000 '''MCARL'''
10000 '''<span style="color:blue">MCARL'''</span>
100000 <span style="color:blue">MCARL</span>
500000 '''MCARL'''
{{out}}
<pre>
4: 3.162
3: 3.166084
2: 3.12281684
1: 3.14371214154
</pre>
 
Line 3,206 ⟶ 3,219:
{{trans|Kotlin}}
{{libheader|Wren-fmt}}
<syntaxhighlight lang="ecmascriptwren">import "random" for Random
import "./fmt" for Fmt
 
var rand = Random.new()
9,476

edits