Skip to content

Chrome extension shouldn’t use modulus to fit random values to wordlist #2

@s4y

Description

@s4y

Using mod to fit random numbers to a range means that the words in the list that could be hit by the mod are twice as likely to be chosen as those that aren’t. 💥

I think the canonical way to handle this is, instead, to keep generating random numbers until you get one that's in range.

Here’s a good example from Python: http://hg.python.org/cpython/file/default/Lib/random.py#l216

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions