The casual.integer generator is noticeably biased away from the ends of the range; the start and end of the range only occur with half the frequency of the other elements.
The reason for this is the use of Math.round and a range of to-from, which is not big enough. A better formula might be:
Math.floor(from + (to - from + 1) * this.random)
Of course, this would break anyone who is depending on the same answers with the same seed, so maybe a new method would be better?
The
casual.integer
generator is noticeably biased away from the ends of the range; the start and end of the range only occur with half the frequency of the other elements.The reason for this is the use of
Math.round
and a range ofto-from
, which is not big enough. A better formula might be:Math.floor(from + (to - from + 1) * this.random)
Of course, this would break anyone who is depending on the same answers with the same seed, so maybe a new method would be better?