Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixing a few mroe smallscale typos
  • Loading branch information
leios committed May 24, 2018
commit 438a6e07388351a06fbadc90688ba5ba942d9d10
2 changes: 1 addition & 1 deletion chapters/monte_carlo/code/julia/monte_carlo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function monte_carlo(n::Int64, radius::Float64)
end

pi_estimate = 4*pi_count/(n*radius^2)
println("Percent error is: ", signif(100*(pi - pi_estimate), 3), " %")
println("Percent error is: ", signif(100*(pi - pi_estimate)/pi, 3), " %")
end

monte_carlo(10000000, 0.5)
2 changes: 1 addition & 1 deletion chapters/monte_carlo/monte_carlo.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Monte carlo methods are famous for their simplicity.
It doesn't take too many lines to get something simple going.
Here, we are just integrating a circle, like we described above; however, there is a small twist and trick.
Instead of calculating the area of the circle, we are instead trying to find the value of $$\pi$$, and
rather than integrating the entire circle, we are only integrating the upper left quadrant of the circle from $$0 < x,y < 1$$.
rather than integrating the entire circle, we are only integrating the upper right quadrant of the circle from $$0 < x,y < 1$$.
This saves a bit of computation time, but also requires us to multiply our output by $$4$$.

That's all there is to it!
Expand Down