Skip to content

safehammad/grazing-goat

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 

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:

  1. The standard built-in (pseudo)random number generation using the rand function.

  2. 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.

Installation

Check out or download from https://github.com/safehammad/grazing-goat.

Usage

To run:

$ clojure -M -m safehammad.grazing-goat

License

Copyright © 2020-2023 Safe Hammad

Distributed under the Eclipse Public License version 1.0.

About

A solution to the Grazing Goat Problem using the Monte Carlo Method.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published