Calculating Areas and Volumes using MCMC
A method for calculating areas and volumes using Markov Chain Monte Carlo techniques.
Calculating Volumes in higher dimensions.
In lower dimensions, we generally have a closed form for finding areas and volumes of known shapes and objects. However, when we don't know the shape or object, we enclose it under a known shape and discretize the known shape into a grid of points. We then say that the ratio of points that fall inside the unknown shape to the total number of points in the known shape is equal to the ratio of the volume of the unknown shape to the volume of the known shape. i.e.,
This makes the formula for the volume of the unknown shape as follows:
This works when we are in lower dimensions, but when we are in higher dimensions, the mere idea of getting into the unknown shape which is enclosed in a known shape is not easy. We may say, "Let us throw darts into it and see how many darts fall inside the unknown shape." But this is not a good idea because the volume of the known shape increases exponentially with the number of dimensions. This makes us to throw many septillions of darts just to make a single dart fall into the unknown shape. So, we need to use a better method to get into the unknown shape. This is where Markov Chain Monte Carlo (MCMC) comes into play.
A small change to the dart throwing method
Instead of enclosing the whole unknown shape in a known shape(sphere in d-dimensions), we can do this thing iteratively by increasing the sphere gradually. Initially, we start with the sphere of radius 1 and then we increase the radius gradually. We can say that the unknown shape is enclosed in a sphere of radius . Now, we throw the darts into the increasing spheres to calculate the volume of the unknown shape. This forms a telescopic series of ratios of volumes, which finally lets us have the volume of the unknown shape(a convex set ). The ratio of volumes can be calculated as follows:
where is the sphere of radius and is the sphere of radius and so on.
Increment of the radius
The most important question is how much should we increase the radius of the sphere compared with the previous radius. This holds a lot of significance because, if we increase it by say 2 units, then the volume of the sphere increases exponentially because, if there are 100 dimensions, it becomes times the previous volume and the next one shall receive very small no. of points than the previous one.
Hence, we need to fix the maximum factor one can increase. Then comes euler's constant.
let us say the factor is at which the next sphere's radius is increased. Then, the volume of the next sphere is times the previous volume. We can say that the maximum factor should be such that , where is euler's constant. Hence, we can say that .
Using taylor series expansion, we can say that . Hence, we can say that the maximum factor should be .
So, we say we need to increment the radius of the sphere by a factor of , where is the number of dimensions. This ensures that the volume of the next sphere does not increase too rapidly, allowing for a more efficient sampling of points within the unknown shape.
How many spheres do we need to enclose the unknown shape?
If the unknown shape is enclosed in a sphere of radius , then we can say that the number of spheres needed to enclose the unknown shape is . This is because we are increasing the radius of the sphere by a factor of each time, and we need to reach a radius of starting from a radius of 1. Thus we receive an order of . The book uses even higher upper bound to be which is definitely larger than .
What about the error?
There ought to be an error in the calculation of the volume at each iteration. But, I would like to have my error at most at the end of the calculation. Then what is the error I can allow at each iteration? Let us derieve it. Let us say we have iterations and each iteration has an error of . Then, the total error at the end of the calculation is given by:
For a very small error , we can use the first order taylor approximation (or binomial approximation) to say that . Hence, we can say that the total error at the end of the calculation is given by:
Hence this shows us that we need to have an error of at most at each iteration to ensure that the total error at the end of the calculation does not exceed . This is crucial for maintaining accuracy in our volume estimation using MCMC methods.
But, we still didn't tell exactly, how much of an error we can allow at each iteration. We just know the maximum allowable error.
If is the radius of the final sphere, then
Taking natural logarithm on both sides, we get:
Using the standard logarithmic approximation for small , we can further simplify this to:
More rigorously, because for all , we can say that:
For aesthetic purposes and to be parameter free, we can replace (d+1) with a safe upper bound of ed. (since for all dimensions ). Hence, we can say that:
By putting all of these together, we can say that the error at each iteration should be at most:
Hence by having an error of at most at each iteration, we can ensure that the total error at the end of the calculation does not exceed .