Monte Carlo Method and Pi Approximation Day
Quside develops new-generation quantum technologies for secure connectivity and efficient computation.
Published on 22 July 2021
Monte Carlo Method and Pi Approximation Day
Pi (π) is probably one of the most recognizable and relevant constants in mathematics. Defined as the ratio between the perimeter of a circle and its diameter, its importance both in geometry and in other fields such as physics, architecture, or engineering is such that, since ancient times, we humans have sought methods to calculate its value, even in an approximate way. It’s not surprising that people decided to celebrate 22/07 as Pi’s approximation day.
As time passed, we have progressed from very crude approximations (such as the Babylonians’ π ≈ 3, which also appears in the Bible) to extraordinarily powerful formulas, such as those proposed by Ramanujan, whose methods, when combined with today’s computers, allow us to know the first 50000000000000 digits of π. Along the way, we have come across useful approximations such as Archimedes’ π ≈ 22/7, which gives rise to this day’s celebration, or Ptolemy’s π ≈ 377/120. We have even seen attempts to legislate the real value of Pi as one of these approximations, as π ≈ 16/5!
We at Quside, as random number lovers, enjoy using another method to calculate π: we warmly call it “The Pepperoni π-zza method”, although some will recognize it better by its regular name: the Monte Carlo method. ?
To calculate π using this method, we take a pizza in a box and start throwing pepperoni slices randomly into the box: the more we throw, the better (the more accurate the calculation and the better the pizza will taste). When we get enough, we count how many slices have fallen on top of the pizza: if we have done it right, the ratio between the number of pepperoni slices on the pizza and the total number of slices used is close to π/4.
The more slices we throw, the closer we get to the real value of Pi: here are some examples of how we get closer and closer the more slices of pepperoni we put on the pizza.
Pizza 1: π ≈ 12/15 x 4 = 3,2
Pizza 2: π ≈ 25/32 x 4 = 3,125
Using a Monte Carlo method to calculate an ultra-precise value of π is rare anyway. However, these tools are widely applied today in countless areas: logistics, finance, insurance, medicine, physics, engineering, … in all of them, a fast and reliable source of pepperoni random numbers, such as the ones we manufacture and sell at Quside, is essential to solving the problems that their users must deal with every single day.
Get to know Quside’s QRNG now, and, in between simulations, you can enjoy Pi’s approximation day by making a nice pizza “à la Monte Carlo”.
Keep reading
- Deployment and integration
QRNG for HSMs and PKI
An HSM generates keys that protect everything else, so the entropy source inside it is the root of the whole hierarchy. What matters for an HSM or a certificate authority is not only that the source is physical, but that its entropy claim is evidenced within the module boundary and can be demonstrated during evaluation and audit.
- Deployment and integration
QRNG form factors, from PCIe card to silicon IP
Quside supplies entropy sources as PCIe cards, FMC modules, embedded modules and licensable silicon IP. The choice is governed by where entropy needs to be generated relative to what consumes it, and by how many units you are building.
- Deployment and integration
Integrating a QRNG: C, Python, Rust and the Linux entropy path
On Linux a hardware entropy source is normally exposed through the kernel random subsystem, so applications keep calling getrandom() and inherit the better seed without changing. Direct access through a device interface or a library is available where an application needs entropy that has not passed through the kernel pool.