JSPM

secure-sample

2.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 166
  • Score
    100M100P100Q82846F
  • License ISC

Secure, sequential (n, N) sampling without replacement

Package Exports

  • secure-sample

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (secure-sample) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

secure-sample

Secure, sequential (n, N) sampling without replacement

Usage

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]

API

secureSample(sampleSize, populationSize)

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

Install

npm install secure-shuffle

Reference

John D. Cook on Stack Overflow

License

ISC