How to use the xorshift.constructor function in xorshift

To help you get started, we’ve selected a few xorshift examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github beaugunderson / poisson-disc-sampler / test / poisson-disc-sampler.js View on Github external
it('should sample points correctly with a specified RNG', function () {
    var WIDTH = 1000;
    var HEIGHT = 500;

    var xorshift = new XorShift([1, 0, 2, 0]);

    // wrap this because we can't just pass the xorshift.random function to the
    // sampler since it relies on the rest of the object (it calls
    // this.randomint);
    function random() {
      return xorshift.random();
    }

    var sampler = poissonDiscSampler(WIDTH, HEIGHT, 10, random);

    var sample;

    var points = 0;

    while ((sample = sampler())) {
      points++;
github nearform / node-clinic-doctor / test / generate-process-stat.js View on Github external
function generateProcessStat (data, noiseLevel) {
  const rng = new xorshift.constructor([
    294915, 70470, 145110, 287911 // from random.org :)
  ])

  function noise () {
    return rng.random() * noiseLevel
  }

  // flatten data structure
  const flat = {
    delay: data.delay,
    cpu: data.cpu,
    rss: data.memory && data.memory.rss,
    heapTotal: data.memory && data.memory.heapTotal,
    heapUsed: data.memory && data.memory.heapUsed,
    external: data.memory && data.memory.external,
    handles: data.handles && data.handles
github kriskowal / kni / kni.js View on Github external
interactive = false;

        } else if (config.toHtml) {
            makeHtml(states, config.toHtml, {
                title: config.htmlTitle,
                color: config.htmlColor,
                backgroundColor: config.htmlBackgroundColor,
            });
            interactive = false;
        }

        var randomer = xorshift;

        if (config.transcript || config.seed) {
            // I rolled 4d64k this morning.
            randomer = new xorshift.constructor([
                37615 ^ config.seed,
                54552 ^ config.seed,
                59156 ^ config.seed,
                24695 ^ config.seed
            ]);
        }

        if (config.expected) {
            read(config.expected, function onTypescript(err, typescript) {
                if (err) {
                    console.error(err.message);
                    process.exitCode = -1;
                    return;
                }
                test(kniscript, typescript);
            });
github kriskowal / kni / verify.js View on Github external
for (var i = 0; i < story.errors.length; i++) {
            console.error(story.errors[i]);
        }
        return {
            pass: false,
            expected: trans,
            actual: errors,
        };
    }

    var states = story.states;

    // TODO support alternate seeds
    var seed = 0;
    // I rolled 4d64k this morning, for kni.js
    var randomer = new xorshift.constructor([
        37615 ^ seed,
        54552 ^ seed,
        59156 ^ seed,
        24695 ^ seed
    ]);

    var writer = new StringWriter();
    var render = new Console(writer);
    var readline = new FakeReadline(writer, answers);
    var engine = new Engine({
        story: states,
        start: 'start',
        handler: handler,
        render: render,
        dialog: readline,
        randomer: randomer
github nearform / node-cephes / build / generate-c-tester.js View on Github external
#include "mconf.h"
#include "cephes.h"
#include 

int error_code = -1;
int mtherr(char *name, int code) {
  error_code = code;
  return 0;
}

int main() {
`;

const footer = `}\n`;

var rng = new XorShift([
  6724524440630955, 4369800304473057,
  1956920014856890, 8721370862793116
]);

const type2printf = {
  'double': '%.20f',
  'int': '%d'
};

const type2zero = {
  'double': '0.0',
  'int': '0'
};

const argGenerators = {
  double: function () {

xorshift

Random number generator using xorshift128+

MIT
Latest version published 3 years ago

Package Health Score

53 / 100
Full package analysis