monte carlo integration and estimating the value of pi
I have talked about estimating the value of pi earlier and have even mentioned the code that I wrote to estimate the value of pi. I did not realize that I was applying the monte carlo integration method to estimate the area of the circle. I have wanted to implement it since I started working with monte carlo methods and once I realized that the method I used to estimate pi was a monte carlo method, I immediately tried to estimate the error in the estimation, which depends on the total number of monte carlo steps or iterations. Error in monte carlo integration is a function of the inverse square root of the total number of monte carlo steps, which is exactly what i saw in the log-log plot of step size vs error in estimation. After a bit of trouble, i ported the code to fortran and got the same results, with fitting and plotting being done on gnuplot. The ipynb file is available here and the fortran file here. I now need to look for more interesting functions which I can apply the monte carlo integration method to. From what I've been reading so far, it's conducive to use monte carlo integration when one is dealing with multi dimensional integration i.e 5 or more dimensions. Atleast I have something to start from now.
On the other hand, as I mentioned yesterday, I got my first segfault on fortran. I tried debugging it with gdb but couldn't understand much. I do know that the code worked perfectly fine until I started defining subroutines to perform the function evaluation and to perform numerical integration. Either way, I need to get these two sorted tomorrow. It's been a good day, let's see if I maintain the same energy tomorrow...
On the other hand, as I mentioned yesterday, I got my first segfault on fortran. I tried debugging it with gdb but couldn't understand much. I do know that the code worked perfectly fine until I started defining subroutines to perform the function evaluation and to perform numerical integration. Either way, I need to get these two sorted tomorrow. It's been a good day, let's see if I maintain the same energy tomorrow...