DSPRelated.com
Forums

Noise modeling ideas

Started by brent June 9, 2011
I am working on a program to display a noise signal.  It contains 100
random amplitude sine waves and 100 random amplitude cosine waves from
1-100 Hz.  I am trying to refresh the screen with the wave form as
fast as I can.  each waveform is 400 points long.  This is
computationally a real processor hog.  I have stored all 100 sine
waves and 100 cosine waves in an array so I am just applying the
random number creation to each wave and summing them up.  I am doing
this brute force, but i have somewhat optimized what I have done thus
far. (BTW my random amplitude is done by summing three random number
generations together to try to achieve a more Gaussian distribution on
the amplitudes)

I am using 40% of my computer processor to refresh this 1 time per
second. ( I deliberately use a somewhat crummy computer when doing
this)

Any ideas for creating a computationally efficient noise in the time
domain that contains 100 frequencies and actually looks like noise
when its done?

A link to what I have done so far is here:

http://www.fourier-series.com/fun/noise1.html

On Jun 9, 1:50&#4294967295;pm, brent <buleg...@columbus.rr.com> wrote:
> I am working on a program to display a noise signal. &#4294967295;It contains 100 > random amplitude sine waves and 100 random amplitude cosine waves from > 1-100 Hz. &#4294967295;I am trying to refresh the screen with the wave form as > fast as I can. &#4294967295;each waveform is 400 points long. &#4294967295;This is > computationally a real processor hog. &#4294967295;I have stored all 100 sine > waves and 100 cosine waves in an array so I am just applying the > random number creation to each wave and summing them up. &#4294967295;I am doing > this brute force, but i have somewhat optimized what I have done thus > far. (BTW my random amplitude is done by summing three random number > generations together to try to achieve a more Gaussian distribution on > the amplitudes) > > I am using 40% of my computer processor to refresh this 1 time per > second. ( I deliberately use a somewhat crummy computer when doing > this) > > Any ideas for creating a computationally efficient noise in the time > domain that contains 100 frequencies and actually looks like noise > when its done?
If you want a *noise* signal, use a random number generator. If you want a sum-of-sines signal, use a look-up table. Rune
On Jun 9, 7:54&#4294967295;am, Rune Allnor <all...@tele.ntnu.no> wrote:
> On Jun 9, 1:50&#4294967295;pm, brent <buleg...@columbus.rr.com> wrote: > > > > > > > I am working on a program to display a noise signal. &#4294967295;It contains 100 > > random amplitude sine waves and 100 random amplitude cosine waves from > > 1-100 Hz. &#4294967295;I am trying to refresh the screen with the wave form as > > fast as I can. &#4294967295;each waveform is 400 points long. &#4294967295;This is > > computationally a real processor hog. &#4294967295;I have stored all 100 sine > > waves and 100 cosine waves in an array so I am just applying the > > random number creation to each wave and summing them up. &#4294967295;I am doing > > this brute force, but i have somewhat optimized what I have done thus > > far. (BTW my random amplitude is done by summing three random number > > generations together to try to achieve a more Gaussian distribution on > > the amplitudes) > > > I am using 40% of my computer processor to refresh this 1 time per > > second. ( I deliberately use a somewhat crummy computer when doing > > this) > > > Any ideas for creating a computationally efficient noise in the time > > domain that contains 100 frequencies and actually looks like noise > > when its done? > > If you want a *noise* signal, use a random number generator. > > If you want a sum-of-sines signal, use a look-up table. > > Rune- Hide quoted text - > > - Show quoted text -
Here is a great and quick pseudo-random number generator. And it is freeware! http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html Enjoy, Clay
On 09-06-2011 @ 13:50:21 brent <bulegoge@columbus.rr.com> wrote:

noise + noise =noise (std and mean doesn't change)

What is the difference between sum of 100 noise samples?


-- 
Mikolaj
>On 09-06-2011 @ 13:50:21 brent <bulegoge@columbus.rr.com> wrote: > >noise + noise =noise (std and mean doesn't change) > >What is the difference between sum of 100 noise samples? > > >-- >Mikolaj >
Uh, no. Assuming you are adding noises drawn from the same distribution (i.i.d. in particular) standard deviation increases with sqrt(N), and both the variance and means sum. As for the OP... an easy way to generate a Gaussian amplitude distribution is to build a simple linear congruential PRN generator (uniform over the range 0 to 1,) then generate two streams of data and apply this equation: Z1 = sqrt(-2 * log(R1)) * cos(2 * pi * R2); % MATLAB syntax Z2 = sqrt(-2 * log(R2)) * sin(2 * pi * R2); where Z1, Z2 are ~N(0, 1) and R1, R2 are ~U(0, 1). Note that in MATLAB, log is the natural logarithm. Of course, if you are using MATLAB, you can just as simply use the randn() function. Mark
>Z1 = sqrt(-2 * log(R1)) * cos(2 * pi * R2); % MATLAB syntax >Z2 = sqrt(-2 * log(R2)) * sin(2 * pi * R2);
I should add that though these equations can be found on the web in various places, I actually got them out of "Discrete-Event System Simulation" by Jerry Banks, et al. Not a bad text I might add. Mark
On Jun 9, 3:45&#4294967295;pm, "taks" <mtakatz@n_o_s_p_a_m.verasent.com> wrote:
> >Z1 = sqrt(-2 * log(R1)) * cos(2 * pi * R2); % MATLAB syntax > >Z2 = sqrt(-2 * log(R2)) * sin(2 * pi * R2); > > I should add that though these equations can be found on the web in various > places, I actually got them out of "Discrete-Event System Simulation" by > Jerry Banks, et al. &#4294967295;Not a bad text I might add. > > Mark
Perhaps it is helpful to know that this is the Box-Muller transform. Clay
On Jun 9, 2:45&#4294967295;pm, "taks" <mtakatz@n_o_s_p_a_m.verasent.com> wrote:
> >Z1 = sqrt(-2 * log(R1)) * cos(2 * pi * R2); % MATLAB syntax > >Z2 = sqrt(-2 * log(R2)) * sin(2 * pi * R2); > > I should add that though these equations can be found on the web in various > places, I actually got them out of "Discrete-Event System Simulation" by > Jerry Banks, et al. &#4294967295;Not a bad text I might add. > > Mark
Is there a typo in these equations (as published in comp.dsp) or are they an exact copy of what is in the text cited, in which case the typo is in the textbook, and is being reproduced here? I am thinking that may be the argument of the log in the second equation should be R1, not R2 ....., and if so, it might be worthwhile daving the value of sqrt(-2 * log(R1)) and re-using it instead of recomputing it. As usual, it all depends on the implementation, e.g. if memory fetches take up more time than re-computation. Dilip Sarwate Dilip Sarwate

taks wrote:

> As for the OP... an easy way to generate a Gaussian amplitude distribution > is to build a simple linear congruential PRN generator (uniform over the > range 0 to 1,) then generate two streams of data and apply this equation: > > Z1 = sqrt(-2 * log(R1)) * cos(2 * pi * R2); % MATLAB syntax > Z2 = sqrt(-2 * log(R2)) * sin(2 * pi * R2);
Two things: 1. Your formulae are wrong. 2. If it is critical for the distribution to have good tails, the random numbers should have enough of bits (32 random bits only provide for reasonable distribution in the range up to 5 x Sigma or so). Below is practical code. //------- u32 Rnd() { static u32 rnd_seed[2] = { 0x12345678, 0xAA551EE1 }; rnd_seed[0] = 1103515245*rnd_seed[0] + 12345; rnd_seed[1] = 1664525*rnd_seed[1] + 1013904223; return rnd_seed[0] + (rnd_seed[1] >> 16); } f64 Gauss_Rnd() { u32 v0 = Rnd(); if(!v0) v0 = 1; u32 v1 = Rnd(); return sqrt(2.0*log(4294967296.0/v0)*sin(v1*2.0*PI/4294967296.0); } Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com
On Jun 9, 11:50&#4294967295;pm, brent <buleg...@columbus.rr.com> wrote:
> I am working on a program to display a noise signal. &#4294967295;It contains 100 > random amplitude sine waves and 100 random amplitude cosine waves from > 1-100 Hz. &#4294967295;I am trying to refresh the screen with the wave form as > fast as I can. &#4294967295;each waveform is 400 points long. &#4294967295;This is > computationally a real processor hog. &#4294967295;I have stored all 100 sine > waves and 100 cosine waves in an array so I am just applying the > random number creation to each wave and summing them up. &#4294967295;I am doing > this brute force, but i have somewhat optimized what I have done thus > far. (BTW my random amplitude is done by summing three random number > generations together to try to achieve a more Gaussian distribution on > the amplitudes) > > I am using 40% of my computer processor to refresh this 1 time per > second. ( I deliberately use a somewhat crummy computer when doing > this) > > Any ideas for creating a computationally efficient noise in the time > domain that contains 100 frequencies and actually looks like noise > when its done? > > A link to what I have done so far is here: > > http://www.fourier-series.com/fun/noise1.html
Use LabView