How to use the pure-rand.congruential32 function in pure-rand

To help you get started, we’ve selected a few pure-rand 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 dubzzz / fast-check / test / unit / check / runner / configuration / QualifiedParameters.spec.ts View on Github external
import * as fc from '../../../../../lib/fast-check';
import * as prand from 'pure-rand';

import { QualifiedParameters } from '../../../../../src/check/runner/configuration/QualifiedParameters';
import { RandomType } from '../../../../../src/check/runner/configuration/RandomType';
import { VerbosityLevel } from '../../../../../src/check/runner/configuration/VerbosityLevel';

const parametersArbitrary = fc.record(
  {
    seed: fc.integer(),
    randomType: fc.constantFrom(prand.mersenne, prand.congruential, prand.congruential32, prand.xorshift128plus),
    numRuns: fc.nat(),
    timeout: fc.nat(),
    path: fc.array(fc.nat()).map(arr => arr.join(':')),
    unbiased: fc.boolean(),
    verbose: fc.constantFrom(VerbosityLevel.None, VerbosityLevel.Verbose, VerbosityLevel.VeryVerbose),
    examples: fc.array(fc.nat()),
    endOnFailure: fc.boolean(),
    skipAllAfterTimeLimit: fc.nat()
  },
  { withDeletedKeys: true }
);

const hardCodedRandomType = fc.constantFrom(
  'mersenne',
  'congruential',
  'congruential32',
github dubzzz / fast-check / src / check / runner / configuration / QualifiedParameters.ts View on Github external
private static readRandomType = (p: Parameters): ((seed: number) => RandomGenerator) => {
    if (p.randomType == null) return prand.xorshift128plus;
    if (typeof p.randomType === 'string') {
      switch (p.randomType) {
        case 'mersenne':
          return prand.mersenne;
        case 'congruential':
          return prand.congruential;
        case 'congruential32':
          return prand.congruential32;
        case 'xorshift128plus':
          return prand.xorshift128plus;
        default:
          throw new Error(`Invalid random specified: '${p.randomType}'`);
      }
    }
    return p.randomType;
  };
  private static readNumRuns = (p: Parameters): number => {

pure-rand

Pure random number generator written in TypeScript

MIT
Latest version published 4 months ago

Package Health Score

81 / 100
Full package analysis