Skip to content Skip to sidebar Skip to footer

Monte Carlo Simulations By Large No Of Trials

Consider that following program. import math import random def inside_unit_circle(point): ''' Compute distance of point from origin ''' distance = math.sqrt(point[

Solution 1:

So you need to run estimate_mystery with increasingly higher numbers of trials. As you do so, it will become clear that the value increases to the following simple expression:

formula

(\sum_{k=1}^{\infty} \frac{e^{i\pi(k+1)}}{2k-1})

It should be noted, however, that this is not the only correct answer. The following would have been valid too, where \zeta is the Riemann zeta function:

formulaalternate

However, this does not include the well-known constant e.


I'm not sure why this is confusing. It's quite clear that the sum expression is correct, and it's written quite clearly: the code below the image is very standard LaTeX formatting for mathematical expressions. But to illustrate its correctness, here's a plot showing the convergence when taking the sum to n, and running estimate_mystery up to n as well:

enter image description here


Hrmm... maybe this wasn't what your question wanted? It should also converge to the following, where \gamma is a unit circle around z=0 on the complex plane:

enter image description here

(-i\oint_\gamma z^{-3}e^{\frac{z}{2}}dz)

Solution 2:

If you try estimate_mystery() method with different inputs such as with, 100, 1000, 10000, 100000), you will see that the result will be 0.81, 0.781 0.7807 0.7855, accordingly.

It means, the more you increase the trial number, the result is getting closer ( converges ) to 0.7855. This number can be defined with Pi.

You can find it just by simple calculation. Pi * x = 0.7855. From this equation we can find that x ~ 0.25. Therefore, 0.7855 can be described with Pi/4.

Post a Comment for "Monte Carlo Simulations By Large No Of Trials"