npm.io
0.0.2 • Published 9 years ago

benford

Licence
MIT
Version
0.0.2
Deps
0
Vulns
0
Weekly
0

Benford

Generates random numbers that follow the Benford distribution.

const uniform = (min, max) => Math.random() * (max - min) + min
const benford = (min, max) => Math.exp(uniform(Math.log(min), Math.log(max)))

That's it. Either npm i -S benford if you like dependencies, or just copy and paste the above code.

Todo

  • Consider using window.crypto.getRandomValues() or crypto.randomBytes() if available
  • Compile down to ES5 (is that really still necessary?)

License

MIT

Copyright (c) 2017 John Tasto