JavaScript Math.random Normal distribution (Gaussian bell curve)?

Mangooxx

I want to know if the JavaScript function Math.random uses a normal (vs. uniform) distribution or not.

If not, how can I get numbers which use a normal distribution? I haven't found a clear answer on the Internet, for an algorithm to create random normally-distributed numbers.

I want to rebuild a Schmidt-machine (German physicist). The machine produces random numbers of 0 or 1, and they have to be normally-distributed so that I can draw them as a Gaussian bell curve.

For example, the random function produces 120 numbers (0 or 1) and the average (mean) of these summed values has to be near 60.

kodvin

I want to know if the JavaScript function Math.random is normal distribution or not

Javascript Math.random is not a Normal Distribution(Gaussian bell curve). From ES 2015, 20.2.2.27 "Returns a Number value with positive sign, greater than or equal to 0 but less than 1, chosen randomly or pseudo randomly with approximately uniform distribution over that range, using an implementation-dependent algorithm or strategy. This function takes no arguments." So the provided collection when n is high enough we will get approximately uniform distribution. All values in the interval will have equal probability of appearance(straight line parallel to the x axis, denoting number between 0.0 and 1.0).

how can I get numbers which are normal distribution

There are several ways of getting collection of numbers with a normal distribution. As answered by Maxwell Collard the Box-Muller transform does transform uniform distribution to normal distribution(the code can be found in Maxwell Collard answer).

An answer to another stackoverflow answer to a question has a reply with other uniform distribution to normal distribution algorithms. Such as: Ziggurat, Ratio-of-uniforms, Inverting the CDF Besides one of the answers says that: says:

The Ziggurat algorithm is pretty efficient for this, although the Box-Muller transform is easier to implement from scratch (and not crazy slow).

And finally

I want to rebuilt a Schmidt-machine (German physicist), the machine produces random numbers of 0 or 1 and they have to be normal distributed so I can draw them in Gaussian bell curve.

When we have only two values (0 or 1) Gaussian curve looks the same as uniform distribution with 2 possible values. That is why a simple

function randomZero_One(){
    return Math.round(Math.random());
}

would suffice. It would return pseudo-randomly with approximately equal probability values 0 and 1.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to draw a Normal Distribution Curve (Bell curve) using CSS and JavaScript?

From Dev

Dealing with normal (Gaussian) distribution

From Dev

normal Gaussian curve on Histogram in R

From Dev

Strange behaviour with Gaussian random distribution

From Dev

Random multivariate normal distribution

From Java

Gaussian distribution function different answer for program and math

From Dev

Create a matrix ( mx n) with gaussian random distribution

From Dev

Plot density curve of mixture of two normal distribution

From Dev

Bell Curve / Normal Disribution Curve On A NVD3 Discrete Bar Chart

From Dev

Bell Curve / Normal Disribution Curve On A NVD3 Discrete Bar Chart

From Dev

Gaussian mixture modelling (Mclust) in R on simple normal distribution fails

From Dev

bell curve using flot

From Dev

How to generate a random normal distribution of integers

From Dev

Generating uniform distribution using Math.random()

From Dev

Javascript Math.random() not *that* random…?

From Dev

Math & JavaScript | Random chances

From Dev

How to make random loss bits follow Gaussian distribution

From Dev

Trying to add normal distribution curve to ggplot, and it's not working

From Dev

How does the distribution of Math.random()*50 + Math.random()*20 compare to Math.random()*70?

From Dev

ggplot: adding normal distribution curve using stat_function to existing histogram and distribution layers

From Dev

Javascript - Math.random as parameter

From Dev

Create a normal distribution-looking pattern in javascript?

From Dev

Fitting a gaussian to a curve in Python

From Dev

How to generate a matrix of random numbers using the normal distribution in AMPL?

From Dev

Probability of occurrence of random variable chosen from Normal Distribution

From Dev

Plot normal distribution when parameters themselves are random variables

From Dev

Running std::normal_distribution with user-defined random generator

From Dev

selecting random rows with normal distribution based on a column in SQL Server 2012

From Dev

C++ - generate random numbers following normal distribution within range

Related Related

  1. 1

    How to draw a Normal Distribution Curve (Bell curve) using CSS and JavaScript?

  2. 2

    Dealing with normal (Gaussian) distribution

  3. 3

    normal Gaussian curve on Histogram in R

  4. 4

    Strange behaviour with Gaussian random distribution

  5. 5

    Random multivariate normal distribution

  6. 6

    Gaussian distribution function different answer for program and math

  7. 7

    Create a matrix ( mx n) with gaussian random distribution

  8. 8

    Plot density curve of mixture of two normal distribution

  9. 9

    Bell Curve / Normal Disribution Curve On A NVD3 Discrete Bar Chart

  10. 10

    Bell Curve / Normal Disribution Curve On A NVD3 Discrete Bar Chart

  11. 11

    Gaussian mixture modelling (Mclust) in R on simple normal distribution fails

  12. 12

    bell curve using flot

  13. 13

    How to generate a random normal distribution of integers

  14. 14

    Generating uniform distribution using Math.random()

  15. 15

    Javascript Math.random() not *that* random…?

  16. 16

    Math & JavaScript | Random chances

  17. 17

    How to make random loss bits follow Gaussian distribution

  18. 18

    Trying to add normal distribution curve to ggplot, and it's not working

  19. 19

    How does the distribution of Math.random()*50 + Math.random()*20 compare to Math.random()*70?

  20. 20

    ggplot: adding normal distribution curve using stat_function to existing histogram and distribution layers

  21. 21

    Javascript - Math.random as parameter

  22. 22

    Create a normal distribution-looking pattern in javascript?

  23. 23

    Fitting a gaussian to a curve in Python

  24. 24

    How to generate a matrix of random numbers using the normal distribution in AMPL?

  25. 25

    Probability of occurrence of random variable chosen from Normal Distribution

  26. 26

    Plot normal distribution when parameters themselves are random variables

  27. 27

    Running std::normal_distribution with user-defined random generator

  28. 28

    selecting random rows with normal distribution based on a column in SQL Server 2012

  29. 29

    C++ - generate random numbers following normal distribution within range

HotTag

Archive