Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Glipp
Lv 7
Glipp asked in Science & MathematicsMathematics · 9 years ago

normally distributed random number generator?

So far I've seen two functions that may be used on excel's uniform random number generator, RAND() to give a normally distributed random number. The one is =NORMINV(RAND()) and the other is =SQRT(-2*LN(RAND()))*SIN(2*PI()*RAND()).

Could someone explain why the second function produces a normally distributed random variable?

2 Answers

Relevance
  • 9 years ago
    Favorite Answer

    That's essentially the Box-Mueller method.

    http://mathworld.wolfram.com/Box-MullerTransformat...

    If you have two independent standard normal random variables x and y as the components of a vector, then the magnitude r = sqrt(x^2 + y^2) will be Rayleigh distributed. f(r) = r e^(-r^2/2), and cumulative distribution F(r) = 1 - e^(-r^2/2).

    The phase will be uniformly distributed on [0, 2pi].

    There's a theorem that says if you want to generate a random variable with an arbitrary distribution, then you generate a uniform random number U on [0, 1], then take X = F^(-1)(U) where F is the cumulative distribution for the distribution you want. That's why you use NORMINV. Well, if F(r) = 1 - e^(-r^2/2), let's invert that.

    U = 1 - e^(-r^2/2)

    1 - U = e^(-r^2/2)

    ln(1 - U) = -r^2/2

    r^2 = -2ln(1 - U)

    r = sqrt(-2 ln(1 - U)). And they've just noted that 1 - U is also a uniform random number on [0, 1], so you can just do r = sqrt(-2 ln(U)). So this makes r a Rayleigh-distributed random number.

    2*pi()*rand() is a uniform random number on [0, 2pi]. So this is taking the vector with Rayleigh distributed magnitude and uniformly distributed phase. This vector has x and y coordinates which are independent normal random variables. The sine gives you the y coordinate.

  • hinch
    Lv 4
    4 years ago

    utilising gadget.Rand in accordance to yet yet another answerer's reaction sounds like a suitable way of producing a random volume. whether, you are able to desire to think approximately the selection of possible numbers the random volume generator is accredited to be certain from. in case you pass with for too large a sort with an greater particular a suggestions greater helpful than your individual's hit factors, then the potential for producing a perilous harm could be severe i.e. your participant will die most of the time. in the journey that your participant had one hundred possible hitpoints, then you particularly ought to opt for for to generate a possible harm between 10 and 20. The NPC ought to desire to strike as much as 5 situations to kill the participant. You get the conception. even however the element is opt for for a perfect style of random numbers.

Still have questions? Get your answers by asking now.