Monte Carlo methods: Difference between revisions
Content added Content deleted
(Added solution for EDSAC) |
|||
Line 1,022: | Line 1,022: | ||
=={{header|EasyLang}}== |
=={{header|EasyLang}}== |
||
<syntaxhighlight lang="text"> |
<syntaxhighlight lang="text"> |
||
proc mc n . . |
|||
for i range n |
|||
for i = 1 to n |
|||
x = randomf |
|||
y = randomf |
|||
if x * x + y * y < 1 |
|||
hit += 1 |
|||
. |
. |
||
. |
|||
print 4.0 * hit / n |
print 4.0 * hit / n |
||
. |
. |
||
numfmt 4 0 |
|||
fscale 4 |
|||
call mc 10000 |
call mc 10000 |
||
call mc 100000 |
call mc 100000 |
||
call mc 1000000 |
call mc 1000000 |
||
call mc 10000000 |
call mc 10000000 |
||
</syntaxhighlight> |
|||
Output: |
Output: |
||
3.1292 |
3.1292 |