Monte Carlo methods: Difference between revisions

m
used a better glyph for pi, added whitespace to the task's preamble, added a ;Task: (bold) header.
(→‎{{header|Elixir}}: change :random -> :rand module)
m (used a better glyph for pi, added whitespace to the task's preamble, added a ;Task: (bold) header.)
Line 1:
{{task|Probability and statistics}}
 
A '''Monte Carlo Simulation''' is a way of approximating the value of a function
where calculating the actual value is difficult or impossible. <br>
Line 5 ⟶ 6:
and then makes a sort of "best guess."
 
A simple Monte Carlo Simulation can be used to calculate the value for π&nbsp; <big><big><math> \pi </math></big></big>.
 
If you had a circle and a square where the length of a side of the square
was the same as the diameter of the circle, the ratio of the area of the circle
to the area of the square would be π&nbsp; <big><big><math> \pi/4 </math></big></big>.
So, if you put this circle inside the square and select many random points
inside the square, the number of points inside the circle
divided by the number of points inside the square and the circle
would be approximately π&nbsp; <big><big><math> \pi/4 </math></big></big>.
 
 
;Task:
Write a function to run a simulation like this, with a variable number of random points to select.
 
Write a function to run a simulation like this, with a variable number
of random points to select. <br>
Also, show the results of a few different sample sizes.
 
For software where the number π&nbsp; <big><big><math> \pi </math></big></big> &nbsp; is not built-in,
we give π&nbsp; <big><big><math> \pi </math></big></big> &nbsp; to a couplenumber of digits:
3.141592653589793238462643383280
<br><br>
 
=={{header|Ada}}==