The Goat of Monte Carlo
This application solves the Grazing Goat Problem, a recreational mathematical problem described as follows:
"Imagine a circular fence that encloses an area of grass. If you tie a goat to the inside of the fence, how long a rope do you need to allow the animal access to exactly half that area?"
Despite this puzzle existing for over 250 years, a method to arrive at an exact solution was only found in 2020.
This application arrives at a very approximate solution using the Monte Carlo Method. Random dots are fired in the coordinate space of the field for multiple trials of rope length. Each trial calculates the proportion of the number of dots landing in the roped area compared to the number of dots landing in the full fenced area. When that proportion is 0.5, we have our solution! The resulting length of the rope is expressed as a multiple of the radius of the enclosed area.
Random Number Generation
Two methods of random number generation are used for comparison:
The standard built-in (pseudo)random number generation using the
Halton sequence, a deterministic sequence of points which appears random but gives a more even "spread" across the coordinate space, making it very suitable for the Monte Carlo method.
Check out or download from https://github.com/safehammad/grazing-goat.
$ clojure -M -m safehammad.grazing-goat
Copyright © 2020-2023 Safe Hammad
Distributed under the Eclipse Public License version 1.0.