# Weighting in Monte Carlo Simulation

This page provides an introduction to the principle of biased sampling in Monte Carlo simulation and the definition of weights in IceCube.

## Monte Carlo Integration

Monte Carlo is a method for calculating the value of definite integrals using random numbers. Consider the multidimensional integral

where \(\bar{x}\) is an m-dimensional vector and \(\Omega\) is a subset of \(\mathbb{R}^m\) with a volume of

The integral can be approximated by the statement

where \(\bar{x}_1, ..., \bar{x}_N\) is sampled from \(\Omega\). If \(\bar{x}_i\) are points sampled from a grid evenly spaced across \(\Omega\) then this is known as a Riemann sum. However, if \(\bar{x}_i\) are points randomly sampled from \(\Omega\) then this is known as Monte Carlo integration. In general Riemann sums are more efficient for 1 dimension and Monte Carlo is more efficient at higher dimensions.

## Biased Sampling

There is no reason that the values of \(\bar{x}_i\) need to be sampled from a uniform distribution on \(\Omega\). It is often advantageous to sample from some other probability distribution function, which is denoted by \(p(\bar{x_i})\). In this case the integral becomes

Note that if \(p\) is the uniform distribution then \(p(\bar{x}_i) = 1 / V\) which simplifies to the statement above for \(I\).

If two samples were produced from two different distributions: \(N_1\) events drawn from \(p_1\) and \(N_2\) events drawn from \(p_2\) then the total pdf for the combined sample \(\bar{x}_1, ..., \bar{x}_{N_1+N_2}\) becomes

So that the Monte Carlo integral statement becomes

To make things easier to to keep track of we can introduce a quantity called the generation bias \(g(\bar{x}_i)\) such that

where the generation bias generalized to M samples is defined as

Note that this result holds even for samples drawn from disjoint surfaces. As long as the pdf for the \(j^{th}\) sample is defined such that \(p_j(\bar{x_i}) = 0\) for events outside of \(\Omega_j\), then the Monte Carlo integral will give the correct answer for integration on the surface of the union of all the \(\Omega_j\).