3 ms·
Just to add the realization I had immediately after lying down: l < s will of course be true for exactly one possible m per segment. All segments are shortened
by MauranKilom 6y ago
Just to add the realization I had immediately after lying down: l < s will of course be true for exactly one possible m per segment. All segments are shortened by s (or, equivalently, one "hit").
This is therefore indeed just a performance optimization: The real check that is required to make all segments have the same number of possible m inside (and that is rejection-sampled around) is l < t, but we don't even need to compute t if l >= s.
The algorithm would work fine if you completely removed the `if (l < s) then` and `end if` lines, it would just compute a remainder more often. Significantly more often for small s.