How to use the seedrandom.alea function in seedrandom

To help you get started, we’ve selected a few seedrandom 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 stanford-oval / almond-cloud / training / synthetic-gen-process.js View on Github external
async function genBasic(args) {
    const tpClient = new Tp.FileClient({
        locale: args.locale,
        thingpedia: './thingpedia.tt',
        entities: './entities.json',
        dataset: './dataset.tt'
    });
    const schemas = new ThingTalk.SchemaRetriever(tpClient, null, true);

    const rng = seedrandom.alea('almond is awesome');

    const options = {
        thingpediaClient: tpClient,
        schemaRetriever: schemas,

        templateFile: 'index.genie',

        rng: rng,
        locale: args.locale,
        flags: args.flags || {},
        maxDepth: args.maxdepth,
        targetPruningSize: args.target_pruning_size,
        debug: false, // no debugging, ever, because debugging also goes to stdout
    };

    const generator = new Genie.BasicSentenceGenerator(options);
github nearform / node-hidden-markov-model-tf / lib / hmm.js View on Github external
function randomUniform (shape, dtype, seed) {
  // This is how randomNormal handles the seed input
  // SEE: https://github.com/tensorflow/tfjs-core/blob/v0.12.0/src/ops/rand.ts
  const seedValue = seed || Math.random();
  const random = seedrandom.alea(seedValue.toString());
  return tf.rand(shape, random, dtype);
}
github stanford-oval / thingtalk / test / test_sentence_generator_manual.js View on Github external
});
    parser.addArgument('--maxdepth', {
        type: Number,
        defaultValue: 6,
        help: 'Maximum depth of synthetic sentence generation',
    });
    parser.addArgument('--turking', {
        nargs: 0,
        action: 'storeTrue',
        help: 'Restrict grammar rules to MTurk-friendly ones.',
        defaultValue: false
    });

    const args = parser.parseArgs();
    const options = {
        rng: seedrandom.alea('almond is awesome'),
        language: 'en',
        targetLanguage: 'thingtalk',
        thingpediaClient: _tpClient,
        turkingMode: args.turking,
        maxDepth: args.maxdepth,
        debug: true
    };

    const generator = new SentenceGenerator(options);
    const transform = new stream.Transform({
        writableObjectMode: true,

        transform(ex, encoding, callback) {
            callback(null, ex.id + '\t' + ex.utterance + '\t' + ex.target_code + '\n');
        },
github stanford-oval / thingtalk / test / test_sentence_generator.js View on Github external
async function main() {
    const options = {
        rng: seedrandom.alea('almond is awesome'),
        language: 'en',
        targetLanguage: 'thingtalk',
        thingpediaClient: _tpClient,
        turkingMode: false,
        maxDepth: 7,
        debug: true
    };

    const generator = new SentenceGenerator(options);
    const writer = new stream.Writable({
        objectMode: true,

        write(ex, encoding, callback) {
            Promise.resolve().then(() => {
                return processOne(ex.id, ex.utterance, ex.target_code);
            }).then(() => {
github stanford-oval / genie-toolkit / test / test_sentence_generator.js View on Github external
async function main() {
    const options = {
        rng: seedrandom.alea('almond is awesome'),
        locale: 'en-US',
        templateFile: path.resolve(path.dirname(module.filename), '../languages/en/thingtalk.genie'),
        thingpediaClient: _tpClient,
        flags: {
            turking: false,
            remote_commands: true,
            policies: true,
            aggregation: true,
            bookkeeping: true,
            triple_commands: true,
            undefined_filter: true,
            timer: true,
            projection: true,
            projection_with_filter: true
        },
        targetPruningSize: 10000,
github 6502ts / 6502.ts / src / tools / rng / factory.ts View on Github external
export function restoreRng(state: any): GeneratorInterface {
    return new SeedrandomGenerator(
        seedrandom.alea('', {
            state
        })
    );
}
github tensorflow / tfjs / tfjs-core / src / ops / rand.ts View on Github external
constructor(
      mean: number, stdDeviation: number, dtype?: keyof RandNormalDataTypes,
      truncated?: boolean, seed?: number) {
    this.mean = mean;
    this.stdDev = stdDeviation;
    this.dtype = dtype;
    this.nextVal = NaN;
    this.truncated = truncated;
    if (this.truncated) {
      this.upper = this.mean + this.stdDev * 2;
      this.lower = this.mean - this.stdDev * 2;
    }
    const seedValue = seed ? seed : Math.random();
    this.random = seedrandom.alea(seedValue.toString());
  }
github stanford-oval / genie-toolkit / tool / sample.js View on Github external
contexts = await readAllLines([fs.createReadStream(args.context_source)])
                .pipe(new DatasetParser({ preserveId: true }))
                .pipe(new ContextSourceLoader())
                .read();
        }

        const constants = await parseConstantFile(args.locale, args.constants);
        const [functionBlackList, deviceBlackList, functionHighValueList, functionWhiteList, deviceWhiteList] =
            await parseSamplingControlFile(args.sampling_control);

        const tpClient = new Tp.FileClient(args.locale, args.thingpedia, null);
        const schemaRetriever = new ThingTalk.SchemaRetriever(tpClient, null, !args.debug);

        const options = {
            rng: seedrandom.alea(args.random_seed),
            locale: args.locale,

            samplingStrategy: args.sampling_strategy,
            functionBlackList,
            deviceBlackList,
            functionHighValueList,
            functionWhiteList,
            deviceWhiteList,
            contexts,

            compoundOnly: !!args.compound_only,
            debug: args.debug
        };

        readAllLines(args.input_file)
            .pipe(new DatasetParser({ contextual: args.contextual, preserveId: true }))
github stanford-oval / genie-toolkit / tool / split-train-eval.js View on Github external
const promises = [];

        const train = new DatasetStringifier();
        const eval_ = new DatasetStringifier();
        promises.push(StreamUtils.waitFinish(train.pipe(args.train)));
        promises.push(StreamUtils.waitFinish(eval_.pipe(args.eval)));
        let test = null;
        if (args.test) {
            test = new DatasetStringifier();
            promises.push(StreamUtils.waitFinish(test.pipe(args.test)));
        }

        readAllLines(args.input_file)
            .pipe(new DatasetParser())
            .pipe(new DatasetSplitter({
                rng: seedrandom.alea(args.random_seed),
                locale: args.locale,
                debug: args.debug,

                train,
                eval: eval_,
                test,

                evalProbability: args.eval_probability,
                forDevices: args.forDevices,
                splitStrategy: args.split_strategy,
            }));

        return Promise.all(promises);
    }
};
github stanford-oval / genie-toolkit / tool / workers / generate-contextual-worker.js View on Github external
module.exports = function worker(args, shard) {
    const tpClient = new Tp.FileClient(args);
    const options = {
        rng: seedrandom.alea(args.random_seed + ':' + shard),
        idPrefix: shard + ':',
        locale: args.locale,
        flags: args.flags || {},
        templateFile: args.template,
        thingpediaClient: tpClient,
        maxDepth: args.maxdepth,
        targetPruningSize: args.target_pruning_size,
        debug: args.debug,
    };
    return new ContextualSentenceGenerator(options);
};

seedrandom

Seeded random number generator for Javascript.

MIT
Latest version published 5 years ago

Package Health Score

70 / 100
Full package analysis

Popular seedrandom functions