Generating only positive random numbers in SQLite
Your method random() % n
for getting a random number within a certain range is flawed, as it will give an uneven distribution. The number zero will come up twice as often as any other number.
Incidentally, using ABS
to make the numbers positive is flawed in the exact opposite way, making the number zero turn up half as often as any other number, so they cancel each other out.
abs(random() % n)