Thread: Gaussian Normal Dist. Formula

  1. #1
    Registered User
    Join Date
    Feb 2013
    Posts
    5

    Gaussian Normal Dist. Formula

    Hey guys, I'm writing a program to display a histogram of 1000 Gaussian distributed numbers. I've generated the numbers using rand and now need to transform them. I have found the following formula to use

    f(x) = exp(-x^2 / (2*sigma^2)) / sqrt(2*pi*sigma)

    and I am unsure how to implement this into a function.

    Any help would be appreciated! Thanks.

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    The values returned by rand() typically approximate a uniform distribution. (Although the quality of implementation varies between libraries).

    Google for techniques to convert a uniform distribution to a gaussian distribution. You will find plenty of information. It is not as simple as simply plugging in the formula you showed (which is the distribution function for a gaussian).
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  3. #3
    Registered User
    Join Date
    Feb 2013
    Posts
    5
    I've come across the Box-Muller method, and it seems like the best way to do it, but to be honest, i'm not really sure how to apply that. A general over view of the process would help greatly.

  4. #4
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    First link to google with the string "box-muller" is this.

    True, it doesn't provide code, but if your want to use the Box-Muller transform, the information is there. The mathematics is pretty simple.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Gaussian Noise
    By DeliriumCordia in forum C Programming
    Replies: 7
    Last Post: 09-24-2012, 02:38 AM
  2. Gaussian Elimination program
    By whatever125 in forum C++ Programming
    Replies: 1
    Last Post: 04-06-2011, 05:11 AM
  3. Normal maps: Get normal x/y/z from color
    By Devils Child in forum Game Programming
    Replies: 2
    Last Post: 08-09-2009, 12:01 PM
  4. Gaussian elimination in C
    By Meander14 in forum C Programming
    Replies: 2
    Last Post: 09-26-2007, 03:43 AM
  5. Gaussian Elimination
    By Fiverz in forum C Programming
    Replies: 1
    Last Post: 02-05-2003, 12:59 PM