Re: Normal Distributed Random Numbers [message #26517] |
Tue, 04 September 2001 14:34  |
thompson
Messages: 584 Registered: August 1991
|
Senior Member |
|
|
"Kay Bente" <KBente@lycos.de> writes:
> Hi
> I have to create arrays with normal distributed random numbers, but with
> variable FWHM (Full width half max/standard deviation sigma?).
> I want to add normal distributed noise to an image, so that the values
> differ around a mean value.
> In IDL there is a procedure to create such arrays RandomN, but you can't
> change the FWHM and I can't find what FWHM the normal distribution there
> has.
> So I would be glad If somone can tell me how to create such arrays (maybe
> outof uniform distributed arrays created with RandomU, I have no idea.
> I'm using IDL 5.4
The RANDOMN() function creates a Gaussian distribution with an average of 0,
and a standard deviation of 1. Mathematically, this is written as
EXP(-0.5*X^2)
If you want a different distribution, e.g. a different average or a different
standard deviation, all you need to do is something
RanVals = AvgVal + Sigma*RANDOMN(Seed, Num)
For example,
RanVals = 500 + 3*RANDOMN(Seed, 10000)
would produce a bunch of random numbers with an average value of 500, and a
standard deviation of 3. In other words, most of the numbers would be between
497 and 503.
(The FWHM of this distribution is 2*Sigma*SQRT(2*ALOG(2)), or about 2.35*Sigma,
but I suspect you're really thinking about the standard deviation Sigma rather
than the FWHM.)
William Thompson
|
|
|