Friday, September 26, 2025
HomeLanguagesJavascriptD3.js randomExponential() Function

D3.js randomExponential() Function

The randomExponential() function is used to return a function that generates the random number based on the exponential distribution.

Syntax:

d3.randomExponential(lambda);

Parameters: It takes only one parameter that is given above and described below.

  • lambda: It is the rate of the exponential distribution function which is equal to the time between events in a Poisson process.

Returns: It returns a function.

Note: The value of the output may be different each time the function is run.

Below given are a few examples of the above function.

Example 1: When lambda is greater than one.

html




<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport"
        content="width=device-width,
                 initial-scale=1.0">
  <title>Document</title>
</head>
<style>
</style>
<body>
  <!-- Fetching from CDN of D3.js -->
  <script type = "text/javascript"
          src = "https://d3js.org/d3.v4.min.js">
  </script>
  <script>
    /*  The value of the output may be
 different each time the function is run.*/
    console.log(d3.randomExponential(5)())
    console.log(d3.randomExponential(5)())
    console.log(d3.randomExponential(5)())
    console.log(d3.randomExponential(5)())
    console.log(d3.randomExponential(5)())
  </script>
</body>
</html>


Output:

Example 2: When the value of lambda is less than one.

html




<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport"
        content="width=device-width,
                 initial-scale=1.0">
  <title>Document</title>
</head>
<style>
</style>
<body>
  <!-- Fetching from CDN of D3.js -->
  <script type = "text/javascript"
          src = "https://d3js.org/d3.v4.min.js">
  </script>
  <script>
    /*  The value of the output may be
 different each time the function is run.*/
    console.log(d3.randomExponential(0.5)())
/* Smaller the lambda greater the random value generated.
    console.log(d3.randomExponential(0.05)())
    console.log(d3.randomExponential(0.005)())
    console.log(d3.randomExponential(0.0005)())
  </script>
</body>
</html>


Output:

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32321 POSTS0 COMMENTS
Milvus
84 POSTS0 COMMENTS
Nango Kala
6690 POSTS0 COMMENTS
Nicole Veronica
11857 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11910 POSTS0 COMMENTS
Shaida Kate Naidoo
6802 POSTS0 COMMENTS
Ted Musemwa
7072 POSTS0 COMMENTS
Thapelo Manthata
6761 POSTS0 COMMENTS
Umr Jansen
6766 POSTS0 COMMENTS