I am making a task which includes running a Monte Carlo simulation and calculating the order of convergence experimentally. I have to calculate (or approximate) the order of convergence using different methods.
One method is reading it from the loglog-graph. I know that the rate of convergence can be read by retrieving the slope of this graph. The problem is that I can't seem to find a way to read the order of convergence from the graph.
So my question is: how can the order of convergence be read from the loglog-graph?
Consider that the real value of output variable is $\alpha$. Following relation provides you the value of output variable for $n$ iterations.
$$\alpha_{MC}=\frac{1}{n}\sum_{i=1}^na_i$$ Where $i\in[1,n]$ are the iterations and $a_i$ is the value of output variable for $i^{th}$ iteration. Hence the error in the final output of MC is: $$\xi=\alpha-\alpha_{MC}$$ How to draw the convergence:
Calculate the average of MC's output after each iteration using aforemetioned relation. You will have $[\alpha_{MC_1}, \alpha_{MC_2}....\alpha_{MC_n}]$. Plot this list versus the number of iteration and another constant line representing the real value. The plot will look like this:
Here is a python code to do this: