My Math Forum  

Go Back   My Math Forum > College Math Forum > Advanced Statistics

Advanced Statistics Advanced Probability and Statistics Math Forum

LinkBack Thread Tools Display Modes
January 8th, 2012, 10:52 PM   #1
Joined: Jan 2012

Posts: 2
Thanks: 0

random number generation with normal distribution

Dear all

I seek the formulation of generating a random number whithin for example 8<x<12 but having the normal distribution.

In Excel there is a built in function to do that which is "norm_rnd". But I need the formulation of creating such number

nsvcivil is offline  
January 9th, 2012, 12:45 AM   #2
Joined: Jun 2011

Posts: 5
Thanks: 0

Re: random number generation with normal distribution


You can do this is several ways. Depending on what you want to achieve, here are some possibilities:

1. Based on the central limit theorem, you can add up an (arbitrary) large amonut of uniformly distributed numbers, and then scale them to your desired mu & sigma.
The more numbers you add, the more it will approach the normal distribution.

2. This is a more general approach (it works for about any distribution), is to take the CDF (cumulative distribution function) of the distribution (in this case, an "erf" function).
Next, you uniformly generate a random number between 0 and 1, and then take the INVERSE CDF function value of that random generated number. i.e.:

You generated y (between 0 & 1), given that the CDF of the normal distribution equals to " 1 + erf( (x-mu)/(sigma*sqrt(2)) ) ", then by solving it to x:
y = 1 + erf( (x-mu)/ ( sigma*sqrt(2)) ), or
erf^-1(y-1) * sigma*sqrt(2) + mu = x

By filling in a random generated y, you will get a randomly normal distributed x out of a PDF with mean "mu" and standard deviation "sigma".
To keep the value between say, 8 and 12, you can either:
* choose your interval for y in such a way that it only can return values for x between 8 and 12. (more elgant)
* put it in a while loop, until it returns a value between 8 and 12. (ugly but easier)
david188288 is offline  
January 9th, 2012, 03:18 PM   #3
Global Moderator
Joined: May 2007

Posts: 6,805
Thanks: 716

Re: random number generation with normal distribution

There is an analytic method to generate two random variables, which are independent and standard normal. This is based on the fact that by using polar coordinates the joint density function for x and y (normal) can be converted into a joint density for u and ?, where u is distributed exponentially and ? is uniform over the unit circle. Then let r=?u, so X=rcos? and Y=rsin?.
mathman is offline  

  My Math Forum > College Math Forum > Advanced Statistics

distribution, generation, normal, number, random

Search tags for this page
Click on a term to search for related topics.
Thread Tools
Display Modes

Similar Threads
Thread Thread Starter Forum Replies Last Post
Multivariate normal distribution and marginal distribution nakys Advanced Statistics 0 October 3rd, 2013 08:27 AM
Random Number Generation PrayForStan Number Theory 1 November 28th, 2012 05:08 AM
Mathematica: Applying rules to random integer generation thesixmax Math Software 12 January 14th, 2012 07:00 PM
Normal distribution with 2 random variables callkalpa Advanced Statistics 0 May 17th, 2010 06:47 AM
Random numbers generation... can they repeat? edu Advanced Statistics 18 April 6th, 2009 05:45 PM

Copyright © 2019 My Math Forum. All rights reserved.