# How to estimate the value of π…(part 2)

In my last blog entry, I had ended by introducing the idea why a Monte-Carlo simulation that estimates a without estimating the error involved in the simulation gives an incomplete picture of the simulation. The Monte Carlo Standard Error (MCSE) is a measure of the accuracy of the simulation. The lower the MCSE, the more accurate the simulation.

Let be the Monte Carlo-estimated value of
and let be the corresponding standard deviation of the simulation.
The MCSE of the simulation would be where would be the size of the generated
scenarios (I belabor this point but we generated numbers so we could get -*pairs* of numbers
and thus we have scenarios)

So, let us tweak the previous program to change the function estimate_pi()

```
1def estimate_pi(n=1000000):
2 nums = 2 * np.random.random_sample((n, 2)) - 1.0
3
4 insides = np.array([1 if inside_circle(x, y) else 0 for x, y in nums])
5 mean = np.mean(insides)
6 sd = np.std(insides)
7 return 4 * mean, 4 * sd/sqrt(n)
```

This generates both the estimate of and the MCSE. For example, I ran the program with , and , which gave the estimates and MCSE values of and for and and for