# Band-limited noise

Discussion in 'General Electronics Chat' started by someonesdad, Mar 28, 2010.

Jul 7, 2009
1,585
141
I've written some software (in python using numpy) that will let the user create a waveform (a numpy array of N real floating point points) from a variety of one and two parameter probability distributions.

I want to let the user band-limit the resulting waveforms if they wish. Here's how I'm doing this. I take the rfft, which is the first half of the normal fft (corresponding to positive frequencies). The user then chooses 0 < p <= 1.0 and I chop the fraction (1 - p) off the right-hand side of the rfft (i.e., set those points to zero). I take the inverse rfft to get the band-limited waveform back.

Questions:

1. Is this an acceptable method of band-limiting the signal? If not, what would you recommend?

2. Are there any numerical surprises that I might encounter?

I've done an hour or two of testing a wide variety of waveforms and this method seems to work exactly as my intuition says it should. I limit p so that it must be >= 2/N; this looks like a good low frequency cutoff because it always yields a sine wave on the things I've tested it on.

Jul 7, 2009
1,585
141
No takers? I thought surely many of you folks would have some background in some digital signal processing topics and could give me some good advice.

I'd extend the question to ask if it's a reasonable way to produce high pass, low pass, notch, and bandpass filters. It's trivial to do with a couple of lines of code in python and numpy and I'm hoping someone will say "Yes, this is OK; here's what you need to worry about though...".

3. ### t_n_k AAC Fanatic!

Mar 6, 2009
5,448
784
It makes sense that this simple approach to filtering should work. I think the only limitation (if it is indeed a limitation in your work) may lie in the (so-called) "boundary effects" that might appear as unwanted artefacts in the reconstructed signal.

I recall that if one tries to reconstruct a "perfect" square wave or pulse which has undergone a time domain --> frequency domain --> time domain transformation via the DFT [or even continuous Fourier Transform??] route, the reconstructed time domain signal will probably have unexpected "ringing" at the edges. I believe that's why (in part) one introduces windowing of the time domain data - irrespective of the signal type. The "un-windowed" non-zero boundary data values appear as amplitude steps in the time domain signal. An imposed step change in the frequency domain components [magnitude & phase] may also give rise to unexpected results in the time domain reconstruction.

Jul 7, 2009
1,585
141
Thanks, t_n_k. I had come across intimations of this and that a naive approach as this could lead to non-causal behaviors, due to the ringing (Gibb's phenomenon?) anomalies at the beginning of the waveform.

However, my application is a graphical waveform creation/modification program and the user could easily just chop these artifacts off or zero them out.

I think I will go ahead and use the approach since it is trivial from a code standpoint. And since the inputs are pseudo-random stochastic variables, any artifacts probably won't be too noticeable.

5. ### t_n_k AAC Fanatic!

Mar 6, 2009
5,448
784
Yep - Gibb's phenomenon - the very phrase I couldn't recall!

On the strength of your suggestion I did a bit of experimenting with your ideas using Excel - which has an FFT algorithm in the data analysis add-on.

I simply generated a sinusoidal time function plus random noise and ran this through the process you suggest - for the low pass filter case. I only went to 128 samples in the time domain.

Works fine - sure, I couldn't exactly reproduce the original (de-noised) sine component but the result was good enough for a confirmation of the viability of the concept.