Skip to content

add Go implementation of monte carlo #165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 29, 2018

Conversation

chin123
Copy link
Contributor

@chin123 chin123 commented Jun 29, 2018

It assumes that we are taking a unit circle, so it takes a radius of 1.0

}
}

var estimate float64
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this instead of estimate := 4.0 * float64(count) / float64(samples)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that was an oversight because the code was slightly different before :) Fixed now

)

func inCircle(x, y float64) bool {
if x*x+y*y < 1.0 { // the radius of an unit circle is 1.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a pet peeve of mine, you can just do: return x*x+y*y < 1.0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦‍♂️ don't know why i did that, thanks for mentioning! Fixed now.

@zsparal zsparal merged commit 6358f9a into algorithm-archivists:master Jun 29, 2018
@chin123 chin123 deleted the go-montecarlo branch June 29, 2018 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants