> On Jul 7, 2018, at 11:49 PM, Keith Medcalf <kmedc...@dessus.com> wrote: > > Why not use MOD (%) as in > > ABS(RANDOM() % 6)
Because modulo bias. If the RHS doesn't evenly divide the size of the range of RANDOM(), some results will be slightly more likely than others. https://zuttobenkyou.wordpress.com/2012/10/18/generating-random-numbers-without-modulo-bias/ <https://zuttobenkyou.wordpress.com/2012/10/18/generating-random-numbers-without-modulo-bias/> Of course in this case, where the range of RANDOM() is probably 2^32, the bias will be very small. But in some use cases the bias can be magnified by subsequent operations and can still skew the eventual result. A Google search turns up several hits that promise fairer algorithms. https://www.google.com/search?client=safari&rls=en&q=random+modulo+bias&ie=UTF-8&oe=UTF-8 <https://www.google.com/search?client=safari&rls=en&q=random+modulo+bias&ie=UTF-8&oe=UTF-8> —Jens _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users