Python shell sessions as examples

I noted that someone had changed another Python shell session used as an example, into the 'normal' definition of a function followed by the shell session just used to show the answer when the function is called.
I don't think this should be done here, as I am attempting to show how the shell might be used for such a task. It is still Python. The repitition of the input expression is because in idle, the built-in graphical IDE for Python, you would hit return in a previous expression to re-enter it. In the non-graphical shell, you can scroll through previous input to re-enter lines. It can give the immediate feedback, and 'spirit of exploration' you get when working with a calculator. --Paddy3118 05:22, 2 October 2008 (UTC)

Error formula in C implementation

What formula is being used for the error calculation in the C Implementation?

At first I thought it was the formula for standard deviation but the code is:

error = val * sqrt(val (1 - val) / sampled) * 4;

The factor 4 is explained because we are not interested in the ratio  , but in   so both the value and the error must be multiplied by 4. The rest of the code translates to:


 


But according to Wikipedia the formula is this:

 


Can somebody explain this more clearly? I'm not yet convinced this is correct

Return to "Monte Carlo methods" page.