GithubHelp home page GithubHelp logo

rlugojr / d3-random Goto Github PK

View Code? Open in Web Editor NEW

This project forked from d3/d3-random

0.0 2.0 0.0 37 KB

Generate random numbers from various distributions.

License: BSD 3-Clause "New" or "Revised" License

JavaScript 100.00%

d3-random's Introduction

d3-random

Generate random numbers from various distributions.

Installing

If you use NPM, npm install d3-random. Otherwise, download the latest release. You can also load directly from d3js.org, either as a standalone library or as part of D3 4.0. AMD, CommonJS, and vanilla environments are supported. In vanilla, a d3 global is exported:

<script src="https://d3js.org/d3-random.v1.min.js"></script>
<script>

var random = d3.randomUniform(1, 10);

</script>

Try d3-random in your browser.

API Reference

# d3.randomUniform([min, ][max]) <>

Returns a function for generating random numbers with a uniform distribution. The minimum allowed value of a returned number is min, and the maximum is max. If min is not specified, it defaults to 0; if max is not specified, it defaults to 1. For example:

d3.randomUniform(6)(); // Returns a number greater than or equal to 0 and less than 6.
d3.randomUniform(1, 5)(); // Returns a number greater than or equal to 1 and less than 5.

Note that you can also use the built-in Math.random to generate uniform distributions directly. For example, to generate a random integer between 0 and 99 (inclusive), you can say Math.random() * 100 | 0.

# d3.randomNormal([mu][, sigma]) <>

Returns a function for generating random numbers with a normal (Gaussian) distribution. The expected value of the generated numbers is mu, with the given standard deviation sigma. If mu is not specified, it defaults to 0; if sigma is not specified, it defaults to 1.

# d3.randomLogNormal([mu][, sigma]) <>

Returns a function for generating random numbers with a log-normal distribution. The expected value of the random variable’s natural logrithm is mu, with the given standard deviation sigma. If mu is not specified, it defaults to 0; if sigma is not specified, it defaults to 1.

# d3.randomBates(n) <>

Returns a function for generating random numbers with a Bates distribution with n independent variables.

# d3.randomIrwinHall(n) <>

Returns a function for generating random numbers with an Irwin–Hall distribution with n independent variables.

# d3.randomExponential(lambda) <>

Returns a function for generating random numbers with an exponential distribution with the rate lambda; equivalent to time between events in a Poisson process with a mean of 1 / lambda. For example, exponential(1/40) generates random times between events where, on average, one event occurs every 40 units of time.

d3-random's People

Contributors

mbostock avatar mef avatar veltman avatar

Watchers

 avatar  avatar

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.