Click to See Complete Forum and Search --> : Uniform Noise --> Normal Noise
yiannakop
May 20th, 2004, 07:56 AM
Rand() in C, and rand of Matlab as you probably know generate uniformly distributed random numbers. I would like to make a function that creates NORMALLY (gaussian) distributed random numbers (maybe using rand()), like randn() of Matlab does. Any ideas how to convert a uniformly distributed sequence to normally distributed sequence.
Thanx in advance,
Theodore
TheCPUWizard
May 20th, 2004, 08:42 AM
Typically this is done with a weighting function. Consider a normal (gaussian) curve where the values are broken into 1000 quantum units (you could use more or less) each containing an equal AREA of the curve [not width].
You count then generate a random [white] number between 0-1000 and use this as an index into the quantum table.
yiannakop
May 20th, 2004, 08:55 AM
Thanx a lot! If I got it right, I generate the pdf I want (e.g. gaussian) then I generate the rand() sequence and use each sample as index in the pdf. Thanx.
PS: I suppose I could use that tecnique with EVERY pdf (not only gaussian)
codeguru.com
Copyright WebMediaBrands Inc., All Rights Reserved.