Secure, sequential (n, N) sampling without replacement
var sample = require('secure-sample')
sample(3, 10) // [0, 5, 9]Random order sample:
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 uniform
distribution [0, populationSize) (populationSize exclusive). The samples
will be sequential, so you may want to shuffle them. See Related for
relevant module.
sampleSize and populationSize must be safe integers. sampleSize must not be
larger than populationSize. If any of these conditions are violated, an error
will be thrown. Something like unassertify
npm install secure-shufflesecure-random-uniform: Generate secure, random, uniform integers, compensating for modulo biassecure-shuffle: Shuffle an array usingsecure-random-uniformas the RNG