GithubHelp home page GithubHelp logo

rogermadjos / randu Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 160 KB

A randomization utility built around Mersenne Twister Pseudo-Random Number Generator

License: MIT License

Python 1.04% JavaScript 39.45% C++ 59.51%

randu's Introduction

randu

Build Status npm version

Randomization utility built around the Mersenne Twister Pseudo-Random Number Generator.

How to install

npm install randu

API

var randu = require('randu');

This will import randu into your project

randu();

Generates a random floating point number in the range [0, 1).

randu(max);

Generates a random floating point number in the range [0, max).

randu(min, max);

Generates a random floating point number in the range [min, max).

randu.randInt();

Generates a random integer in the range [0, 4294967296).

randu(max);

Generates a random integer in the range [0, max).

randu(min, max);

Generates a random integer in the range [min, max).

randu.randString(len, charset);

Generates a random string with the length len. The result contains only the characters found in charset. The default value of charset is ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789

randu.selectRandomIndex(weights);

Generates a random integer based on weights. e.g. If weights = [1, 2, 1], 0 has 0.25 probability of being selected, 1 has 0.5 and so on.

randu.shuffle(input)

Generates a random permutation of the array input. input is immutable.

License

MIT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.