Results 1 to 4 of 4

Math Help - Function generating normal distribted values?

  1. #1
    Senior Member TriKri's Avatar
    Joined
    Nov 2006
    Posts
    358
    Thanks
    1

    Function generating normal distribted values?

    Hi!

    I have been thinking before of function generating a normal distributed value from a random number evenly distributed between 0 and 1, but I have given up and declared it impossible by using simple formulas.

    Then yesturday, in a programming forum, a guy presented a code line to generate a normal distributed value with a simple formula! But not by using a random number, but by using two random numbers!

    The formula looks like this:

    \mu\ + \sigma\cdot\sqrt{-2\log(r_1)}\cdot\sin(r_2 2\pi)

    where \mu is the mean, \sigma is the standard derivation, and r_1,\ r_2 is two random numbers both evenly distributed between 0 and 1. Supposably the logarithm is ment to be the natural logarithm.

    I hav already found the square root to have the probability distribution function f(x)\ =\ x\cdot e^{-\frac{x}{2}}, and the sinus function to have the distribution function g(x)\ =\ \frac{1}{2\pi\sqrt{1-x^2}}, but now is the problem, what is the distributing function h of the product of the square root and the sin function?

    I wrote down the following formula, but I don't know if it's true:

    h(a)\ =\ \int_{-\infty}^{+\infty}f(x)\cdot g\left(\frac{a}{x}\right)\cdot\frac{a}{x^2}\cdot dx\ =\ \int_{-\infty}^{+\infty}g(x)\cdot f\left(\frac{a}{x}\right)\cdot\frac{a}{x^2}\cdot dx\

    Someone who knows if it is true? Is this some kind of cartesian product between distribution functions? And if it is true, is there any way to simplify the integral?

    Edit: It should probably be a factor two of that, so:
    h(a)\ =\ 2\ \int_{-\infty}^{+\infty}f(x)\cdot g\left(\frac{a}{x}\right)\cdot\frac{a}{x^2}\cdot dx\ =\ 2\ \int_{-\infty}^{+\infty}g(x)\cdot f\left(\frac{a}{x}\right)\cdot\frac{a}{x^2}\cdot dx\
    Last edited by TriKri; October 6th 2007 at 09:46 AM.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by TriKri View Post
    Hi!

    I have been thinking before of function generating a normal distributed value from a random number evenly distributed between 0 and 1, but I have given up and declared it impossible by using simple formulas.

    Then yesturday, in a programming forum, a guy presented a code line to generate a normal distributed value with a simple formula! But not by using a random number, but by using two random numbers!

    The formula looks like this:

    \mu\ + \sigma\cdot\sqrt{-2\log(r_1)}\cdot\sin(r_2 2\pi)

    where \mu is the mean, \sigma is the standard derivation, and r_1,\ r_2 is two random numbers both evenly distributed between 0 and 1. Supposably the logarithm is ment to be the natural logarithm.

    I hav already found the square root to have the probability distribution function f(x)\ =\ x\cdot e^{-\frac{x}{2}}, and the sinus function to have the distribution function g(x)\ =\ \frac{1}{2\pi\sqrt{1-x^2}}, but now is the problem, what is the distributing function h of the product of the square root and the sin function?

    I wrote down the following formula, but I don't know if it's true:

    h(a)\ =\ \int_{-\infty}^{+\infty}f(x)\cdot g\left(\frac{a}{x}\right)\cdot\frac{a}{x^2}\cdot dx\ =\ \int_{-\infty}^{+\infty}g(x)\cdot f\left(\frac{a}{x}\right)\cdot\frac{a}{x^2}\cdot dx\

    Someone who knows if it is true? Is this some kind of cartesian product between distribution functions? And if it is true, is there any way to simplify the integral?

    Edit: It should probably be a factor two of that, so:
    h(a)\ =\ 2\ \int_{-\infty}^{+\infty}f(x)\cdot g\left(\frac{a}{x}\right)\cdot\frac{a}{x^2}\cdot dx\ =\ 2\ \int_{-\infty}^{+\infty}g(x)\cdot f\left(\frac{a}{x}\right)\cdot\frac{a}{x^2}\cdot dx\
    Google for Box Muller transform or algorithm.

    The idea is to generate (a,b) from a bivariate normal distribution, by
    generating polar coordinates (r, theta) as r and theta are independent and
    have distributions which are easily generated. Then converting to cartesians
    to give two independent normally distributed RVs

    RonL
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Senior Member TriKri's Avatar
    Joined
    Nov 2006
    Posts
    358
    Thanks
    1
    So when you have got this kind of complicated integrals you know you're on the wrong track... Now I got it though. If the first distribution function I got is divided by the circumstance of a circle with radie x, it will be proportional to ordinary normal distrubution function. I saw that I had forgot a 2 in the formula, it should be f(x)\ =\ x\cdot e^{-\frac{x^2}{2}}.

    Maybe the integrals could be solved if x was substituted with e^x, but who cares anyway ^^

    One more question about the normal distribution, why did one decide to use that formula to begin with? What's the background?
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by TriKri View Post
    So when you have got this kind of complicated integrals you know you're on the wrong track... Now I got it though. If the first distribution function I got is divided by the circumstance of a circle with radie x, it will be proportional to ordinary normal distrubution function. I saw that I had forgot a 2 in the formula, it should be f(x)\ =\ x\cdot e^{-\frac{x^2}{2}}.

    Maybe the integrals could be solved if x was substituted with e^x, but who cares anyway ^^

    One more question about the normal distribution, why did one decide to use that formula to begin with? What's the background?
    It is important because it is the limiting form of the distribution of the
    mean (and/or sum) of independent identically distributed random variables.
    Which means that often in a system where the state is the result of a large
    number of comparable disturbances on a deterministic process the observed
    state will have a distribution close to normality.

    One reason for this is the the Gaussian density is one of the distributions
    which is its own Fourier transform (give or take a constant here or there).

    RonL
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Moment Generating function of a normal variable
    Posted in the Advanced Statistics Forum
    Replies: 2
    Last Post: January 11th 2012, 03:15 PM
  2. Expected values & Moment-generating function (MGF)
    Posted in the Advanced Statistics Forum
    Replies: 2
    Last Post: December 1st 2011, 01:16 AM
  3. Replies: 1
    Last Post: December 4th 2010, 10:06 PM
  4. Moment Generating for Normal
    Posted in the Advanced Statistics Forum
    Replies: 3
    Last Post: August 7th 2009, 04:27 AM
  5. Method of moment generating function normal distribution
    Posted in the Advanced Statistics Forum
    Replies: 1
    Last Post: November 25th 2008, 03:22 AM

Search Tags


/mathhelpforum @mathhelpforum