A weighting function must first be normalized to a probability density. The constant choice on meansEquivalently, transform and use the already normalized on . Independent samples give the unbiased Monte Carlo integration estimator
function uniform_monte_carlo(f, a, b, N):
require N >= 2
total = 0
total_squared = 0
for j in 1,...,N:
u = independent_uniform_0_1()
value = f(a+(b-a)*u)
total += value
total_squared += value*value
average = total/N
sample_variance = (total_squared-N*average*average)/(N-1)
integral = (b-a)*average
standard_error = abs(b-a)*sqrt(sample_variance/N)
return integral, standard_errorFor a general positive normalized importance density , replace each sample contribution by with . Here the uniform choice is the special case of importance sampling that assigns equal weight to every region of equal length.
Articles by others on the same topic
There are currently no matching articles.