JSPM

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

Sobol quasi random sample generator

Package Exports

  • sobol

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 (sobol) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

npm version install size

sobol

Sobol quasi random sample generator. Sobol sequences are an example of quasi-random low-discrepancy sequences. See Wikipedia.

This generator handles up to 21201 dimensions.

Install

npm install sobol

Usage

Example: Estimate π by calculation sobol vectors inside and outside the unit circle.

const { SobolSequenceGenerator } = require("sobol");

var sobol = new SobolSequenceGenerator(2); // Dimension 2
sobol.nextVector(); // Skip first

var nbIn = 0;
var nbTot = 0;
for (var i = 0; i < 10000; i++) {
    var x = sobol.nextVector();
    if (x[0] * x[0] + x[1] * x[1] < 1) nbIn++;
    nbTot++;
}
console.log((4 * nbIn) / nbTot); // Should output 3.142