Like Tree1Likes
  • 1 Post By grumpy

Gaussian Normal Dist. Formula

This is a discussion on Gaussian Normal Dist. Formula within the C Programming forums, part of the General Programming Boards category; Hey guys, I'm writing a program to display a histogram of 1000 Gaussian distributed numbers. I've generated the numbers using ...

  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,531
    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 in reply to you, it is likely you deserve it. Suck it up, sunshine, 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,531
    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.
    Crossfire likes this.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy in reply to you, it is likely you deserve it. Suck it up, sunshine, 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, 03:38 AM
  2. Gaussian Elimination program
    By whatever125 in forum C++ Programming
    Replies: 1
    Last Post: 04-06-2011, 06: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, 01:01 PM
  4. Gaussian elimination in C
    By Meander14 in forum C Programming
    Replies: 2
    Last Post: 09-26-2007, 04:43 AM
  5. Gaussian Elimination
    By Fiverz in forum C Programming
    Replies: 1
    Last Post: 02-05-2003, 12:59 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21