You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If it's in the circle, we increase an internal count by one, and in the end,
@@ -56,14 +58,14 @@ If we use a small number of points, this will only give us a rough approximation
56
58
The true power of monte carlo comes from the fact that it can be used to integrate literally any object that can be embedded into the square.
57
59
As long as you can write some function to tell whether the provided point is inside the shape you want (like `in_circle()` in this case), you can use monte carlo integration!
58
60
This is obviously an incredibly powerful tool and has been used time and time again for many different areas of physics and engineering.
59
-
I can gaurantee that we will see similar methods crop up all over the place in the future!
61
+
I can guarantee that we will see similar methods crop up all over the place in the future!
60
62
61
63
# Example Code
62
64
Monte carlo methods are famous for their simplicity.
63
65
It doesn't take too many lines to get something simple going.
64
66
Here, we are just integrating a circle, like we described above; however, there is a small twist and trick.
65
67
Instead of calculating the area of the circle, we are instead trying to find the value of $$\pi$$, and
66
-
rather than integrating the entire circle, we are only integrating the upper right quadrant of the circle from $$0 < x,y < 1$$.
68
+
rather than integrating the entire circle, we are only integrating the upper right quadrant of the circle from $$0 < x,y < 1$$.
67
69
This saves a bit of computation time, but also requires us to multiply our output by $$4$$.
68
70
69
71
That's all there is to it!
@@ -73,6 +75,9 @@ Feel free to submit your version via pull request, and thanks for reading!
0 commit comments