I want to use the sample average $(X_1 + .... X_n)/n$ as a substitute for the expectation $\mathbb{E}(X)$. As claimed by the weak law of large numbers, as n increases the sample average should converge to $\mathbb{E}(X)$.
I wish to use this logic in my project, where the $X_i$ are iid exponential random variables. A simple code, however, does not demonstrate this well. This is because when we add the $n$ numbers, $X_1, ..., X_n$, it usually results in a large number and most of the precision is lost. So when I divide by $n$, the difference $|(X_1 + ... X_n)/n - \mathbb{E}(X)|$ is never very small even when I increase $n$ by a large amount.
I have tried some simple manipulations such as taking sub sums and then taking the total average. Even here I seem to be suffering from the same problem.
Is there a neat way of achieving errors less than, say, $10^{-8}$.