Secure, sequential (n, N) sampling without replacement
npm install secure-samplesecure-sample> Secure, sequential (n, N) sampling without replacement
``js
var sample = require('secure-sample')
sample(3, 10) // [0, 5, 9]
`
Random order sample:
`js
var sample = require('secure-sample')
var shuffle = require('secure-shuffle')
shuffle(sample(3, 10)) // [6, 2, 8]
`
Will return an array with sampleSize number of unique samples from the uniform0, populationSize)
distribution (populationSize exclusive). The samples for
will be sequential, so you may want to shuffle them. See [Related
relevant module.
sampleSize and populationSize must be safe integers. sampleSize must not bepopulationSize
larger than . If any of these conditions are violated, an errorunassertify
will be thrown. Something like
`sh`
npm install secure-shuffle
* secure-random-uniform: Generate secure, random, uniform integers, compensating for modulo bias
* secure-shuffle: Shuffle an array using secure-random-uniform` as the RNG
John D. Cook on Stack Overflow