Dear all,
Testing Rand() on MC algorithm for estimating integral of Sine from 0 to Pi,
only returns 50% of the expected confidence interval.
Can anybody see, where my code breaks?
n = 1000
in_ci = 0
for i in 1:500
sin_arr = map(x → sin(x), pirand(n))
lower = pimean(sin_arr) - 1.96std(sin_arr)/sqrt(n)
upper = pimean(sin_arr) + 1.96*std(sin_arr)/sqrt(n)
if (lower <= 2) && (upper >= 2)
in_ci += 1
end
end
println("For n = ", n, " share of estimates in CI.: ", in_ci/500)
Result.:
For n = 1000 share of estimates in CI.: 0.468