Monte Carlo is a beautiful process that can be used to address many, many problems. One of my favorites is that it can be used to estimate the value of \pi. First of all, we know that \pi is the ratio between the radius of a circle, squared, and its area. We can use that to Monte Carlo to estimate this ratio.
If you are not familiar with the Open Science Grid (OSG), it is a large high-throughput computer available as a national user facility. Unlike some other supercomputer facilities, the OSG is not intended for tightly-coupled jobs. And calculating \pi via Monte Carlo is a very loosely-coupled job. In fact, one of the samples for using the OSG in R is exactly this.
About a year ago, I redid the sample using the newish programming language Rust. Rust is getting a lot of press as a new systems programming language and a lot of its memory safety features. I think this makes it a good candidate for numerical programming. So I ported the R example over to Rust, which required a bit of work, but was doable. You can see the result here:
I will admit that the Rust programming language fascinates me. It’s got all the things I want in a programming language, that I normally get from C, and also gives me some measure of protection against really screwing up. Not that I do that much…or even have a use for, anymore.
Of course, there’s nothing quite like a physical analog, and this physicist decided to use a shotgun to replicate the Monte Carlo approach!
Do not try this at home.