I want to find the Monte Carlo simulation of the integral $$\int_0^1 \sqrt{1-x^2}\mathrm dx$$
The Cesàro mean is $$I_n=\frac1n\sum_{k=1}^{n} f(U_k) $$ I want to plot the scatter plot ((1,$I_1$)(2,$I_2$)....(500,$I_{500}$)). First I generate random variables:
u = RandomReal[1, 500]
Then I find the function value at these points:
f = (1 - u^2)^(0.5)
Then I do the partial sum,
s = Accumulate[f]
But I want the sample mean for all n
, not only sample mean for n=500
. In s
I have all partial sums, but I do not know how to divide them by corresponding n
.
I should have the following graph.
Update: With the suggestion of ilian, I got the following graph.
Quite different, I am thinking why. Any suggestion would be appreciated!
s = Accumulate[f] / Range[Length[f]]
? $\endgroup$