1. What is this algorithm doing?
Imagine laying out a yardstick and partitioning it proportionally according to the individual parents’ fitnesses. For $M$ offspring particles, you want to find $M$ equally spaced points (think np.linspace
) along this yardstick. The partition that the $i$’th point lies in determines the parent that gets to produce the $i$’th offspring. The $r$ in the algorithm is simply choosing a uniform-at-random starting point for your linspace
, which of course needs to be in the interval $(0, \frac{1}{M})$ for you to be able to fit all $M$ of your points. This randomness ensures that the resampling is fair and also not completely deterministic.
2. Why does this strategy work?
TLDR; A particle filter’s convergence rate is inversely proportional to the variance in the parents’ offspring counts. Low variance means fast convergence.
NOTE: Below, I discuss (but never explicitly mention) the concept of variance effective population size.
The effectiveness of this resampling strategy makes a lot of sense when you consider that the particle filter is, at its core, an evolutionary algorithm (EA). All EAs tend to lose diversity because of the random sampling step, at a rate proportional to the variance in how many offspring the parents produce. This effect is known as genetic drift, and it adversely affects biological populations as well. As a result of this diversity loss, the EA prematurely converges to suboptimal solutions. This is bad news.
Intuitively, genetic drift makes sense. When parents are chosen at random (the most common setup), those with low fitness/quality are likely to get skipped and produce zero offspring and be eliminated from the gene pool, thus reducing the population’s diversity. Now, the rate at which natural selection improves a population’s fitness is directly proportional to the population’s diversity—diversity is literally the fuel that drives natural selection. Genetic drift reduces the the diversity, thus decreasing the rate at which the population’s fitness can improve and causing the aforementioned bad news.
Let’s now look at the low-variance resampling method. This method gives almost every parent exactly the number of offspring that they would be expected to get with the random sampling, without the extra uncertainty (variance). This reduces genetic drift and greatly increases the efficiency with which the particle filter can improve its solution and/or adapt to changing conditions.