Comment 24 for bug 1406458

Revision history for this message
Jaspervdg (jaspervdg) wrote :

Instead of setting the gradient to a constant value, I would recommend simply using rejection sampling (which is more or less the standard solution to this type of problem). This would NOT affect seeds without this issue, while avoiding introducing bias (which setting the gradient to a constant value might do). This would involve changing out the existing for-loop filling the gradient for something like this piece of code:

      do {
        for (j = 0; j < 2; j++)
          fGradient[k][i][j] = (double)(((lSeed = random(lSeed)) % (BSize + BSize)) - BSize) / BSize;
      } while(fGradient[k][i][0] == 0 && fGradient[k][i][1] == 0);

(In case any one is wondering, this is highly unlikely to be slow, given that the probability of getting two zeros is about 1 in 65536.)