[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference rusure::math

Title:Mathematics at DEC
Moderator:RUSURE::EDP
Created:Mon Feb 03 1986
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:2083
Total number of notes:14613

1549.0. "Generating Normal Data" by IMTDEV::ROBERTS (Reason, Purpose, Self-esteem) Mon Jan 27 1992 15:16

    I have a calculator with the "usual" functions; i.e., + - X / ^. It
    also has a RND function which returns a number in the range [0,1) with
    equal probability. There's also plenty of memory.
    
    Given a known mean, M, and standard deviation, s, I'd like to generate
    numbers with a normal distribution. Can it be done? If not, can it be
    approximated closely? How?
    
    Dwayne
    
T.RTitleUserPersonal
Name
DateLines
1549.1ZFC::deramoDan D'EramoMon Jan 27 1992 16:0912
It could be done "exactly" if you had some of the transcendental
functions and I think sqrt.  I don't remember the formula, it involved
generated two random numbers from the uniform distribution on [0,1) and
rejecting them if they fell outside the unit circle, and manipulating
them somehow otherwise to get two random numbers from a unit normal
distribution.

With just + - X / ^ you can try the rough approximation of taking the
sum of 12 random numbers then subtracting 6.  I don't know how far off
that is.

Dan
1549.2Depends on the application.CADSYS::COOPERTopher CooperMon Jan 27 1992 16:310
1549.3Depends on the application.CADSYS::COOPERTopher CooperMon Jan 27 1992 16:3214
    It seems odd to have a non-scientific calculator with a RND function,
    but the sum-of-uniforms method mentioned by Dan is probably your only
    real possibility. Basically, it gives pretty good results for most of
    the numbers generated.  The distribution of the tails are pretty far
    off, though, so some percentage of the time you'll get
    not-particularly-normal results.  If you just need numbers that are
    roughly normal, that's probably OK -- particularly since its unlikely
    that you'll be generating almost by hand enough normal r.n.'s to make
    the differences that obvious.  If its programmable, you might consider
    summing 24 RNDs, subtracting 12 instead of 6, then dividing by 2.  That
    would probably push the bad region out to where it is of little
    concern.

				    Topher
1549.4SuggestionsCIVAGE::LYNNLynn Yarbrough @WNP DTN 427-5663Mon Jan 27 1992 16:4612
>With just + - X / ^ you can try the rough approximation of taking the
>sum of 12 random numbers then subtracting 6.  I don't know how far off
>that is.

There is nothing magic about 12 here: it's just the smallest n for which 
summing n samples from a uniform distribution and subtracting n/2 gives a
decent approximation to a normal distribution. More samples, better
results. The comparison is good out to around 3 sigma, I think.

As for the "circle" formula, look at routine GASDEV (short for Gaussian 
Deviates) in "Numerical Recipes". It's compact enough to use on a
calculator with sqrt, random, and log keys, I think.
1549.5Magic number 12CADSYS::COOPERTopher CooperMon Jan 27 1992 17:4712
RE: .4 (Lynn)

>There is nothing magic about 12 here: it's just the smallest n for which

    The only "magic" about 12 is that it results in a standard deviation
    of 1, thereby avoiding having to scale in order to get a standard
    normal distribution.  The variance (standard deviation squared) of
    the sum of N Uniform(0..1) random numbers is N/12 (the variance of
    the sum of any random numbers is the sum of the random numbers'
    variances, and the variance of a unit uniform random number is 1/12).

				Topher
1549.6IMTDEV::ROBERTSReason, Purpose, Self-esteemMon Jan 27 1992 18:104
    Thanks, all.
    
    Dwayne
    
1549.7Another MethodFASDER::MTURNERMark Turner * DTN 425-3702 * MEL4Mon Jan 27 1992 20:284
    See 755.n.  This method may be too slow for you, though, unless 
    your calculator will allow you to store the formula for the normal
    distribution.  The advantage to the method is its flexibility: it'll
    convert uniform distributions to any other type.