Results 1 to 2 of 2

Thread: Random numbers in Gaussian distribution

  1. #1

    Thread Starter
    Frenzied Member zaza's Avatar
    Join Date
    Apr 2001
    Location
    Borneo Rainforest Habits: Scratching
    Posts
    1,486

    Random numbers in Gaussian distribution

    This code generates random numbers in a Gaussian distribution, rather than uniformly (although there is a uniform pseudo-random number generator in there...).
    The usual RNG, picking integers in the range 0 to 10, would tend to pick each of them an equal number of times, as the number of picks gets very large.
    This RNG preferentially picks numbers in the centre of the distribution, according to the specified mean (centre) and standard deviation (width).

    It is in an Excel sheet for convenience of viewing - simply enter a mean and sd in the yellow boxes and push "Go". There are further instructions on the sheet itself.

    The code is translated into VBA from Numerical Recipes in C, which are incredibly useful maths programming books. They can even be downloaded at http://www.nr.com.

    The translation to .Net should be pretty straightforward, hence I haven't worried about it.

    Have fun

    zaza
    Attached Files Attached Files

  2. #2
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Random numbers in Gaussian distribution

    If you want to quickly approximate gaussian distribution you can always just take the average of 2 random numbers. (or the more randoms you take the average from the tighter the bell curve gets).
    I don't live here any more.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width