top of page
  • Writer's pictureFreddie Rawlins

Monte Carlo Integration

After seeing a video introducing the idea of calculating Pi by throwing darts at a circle, I discovered the principle of "Monte Carlo Integration". This is where a definite integral is evaluated not through numerical analysis, but by judging the proportion of "darts", in this case points, that fall in a given area.


The algorithm generates a random point within a certain area (defined by the bounds of the integral and a fairly arbitrary height). It then checks whether or not this falls underneath the line (i.e. within the area). The proportion of those that do fall inside the area, multiplied by the known total area, is therefore the area under the graph. This becomes more and more accurate the more points are generated, but it does not take long for the returned value to converge to something very close to the real answer.


While this is in general not super computationally efficient unless you want a very rough estimate for lots of graphs very quickly, it is an interesting way of computing it that bears almost no relation to the complexity of the graph. Even functions that cannot be easily integrated normally are treated identically to standard functions. This then is not designed to be the most efficient or accurate integral calculator, but is an interesting visualization of the algorithm.



24 views0 comments

Recent Posts

See All
bottom of page