Why does this Matlab snippet create biased Fourier waveforms?

In summary, the conversation discusses the creation of biased Fourier waveforms in a Matlab snippet. The snippet uses 20 parameters to describe waveforms, including Fourier coefficients, frequency, and phase. These parameters are assigned random values within a specific range. However, upon further inspection of the code, it is revealed that there was an additional factor being multiplied, leading to the observed bias.
  • #1
Andrew732
9
0
Why does this Matlab snippet create "biased" Fourier waveforms?

I'm trying to search through the space of all possible waveforms (or a reasonable approximation of that space), where waveforms are described by 20 parameters: the first 9 Fourier coefficients for sine terms a(1:9), the first 9 Fourier coefficients for cosine terms b(1:9), a frequency parameter w, and a phase parameter p. The range of the parameters are uniform random over the range [-0.2, 0.2] for each element in a and b, [-1, 1] for w, and [-2 * pi, 2 * pi] for p. The Matlab code that creates a waveform using the parameters is simply:

Code:
t = 0:0.1:10;
wave = zeros(1, numel(t));
for count = 1:9
s = a(count) * sin(count1 * w * t + p);
s = s + b(count) * cos(count1 * w * t + p);
wave = wave + s;
end

This makes waveforms that are fine for my purposes except for a bias that I have noticed over thousands of runs and that I can't explain. Given the uniform random values for the parameters, why would the values of the waveform be greater than 0 significantly more often than 50% of the time? This is not a homework question, just something that's come up in a program I'm writing. I'm mostly just curious and am probably doing something dumb. Thanks for any help!
 
Physics news on Phys.org
  • #2


Well assuming that you're using the rand() function you should have like a 67% change of being within one standard deviation of 0.

What is the code that you are using to generate your interval of [-2*pi,+2*pi]?
 
Last edited:
  • #3


Actually, phrasing the question forced me to take another look at my code and I discovered that I was multiplying everything by another factor, unlike in the code I actually posted, so there's no bias anymore. Thanks anyways!
 

1. Why is the Fourier transform necessary in signal processing?

The Fourier transform is necessary in signal processing because it allows us to analyze and decompose complex signals into simpler sinusoidal components. This makes it easier to understand and manipulate signals in both the time and frequency domains.

2. How does the Matlab snippet create biased Fourier waveforms?

The Matlab snippet could potentially create biased Fourier waveforms if the input signal is not properly centered around zero. This can happen if there is a DC offset in the signal or if the signal is not symmetric. In such cases, the resulting Fourier waveform will be shifted or distorted, leading to biased results.

3. Can bias in Fourier waveforms affect the accuracy of signal analysis?

Yes, bias in Fourier waveforms can affect the accuracy of signal analysis. This is because the presence of a bias can introduce errors in the amplitude and phase of the resulting Fourier components, leading to incorrect interpretations of the signal.

4. How can we avoid biased Fourier waveforms in Matlab?

To avoid biased Fourier waveforms in Matlab, it is important to properly preprocess the input signal. This involves removing any DC offset and ensuring that the signal is centered around zero. It is also important to use appropriate windowing techniques to reduce spectral leakage and improve the accuracy of the Fourier transform.

5. Are there any alternative methods to the Fourier transform for signal analysis?

Yes, there are alternative methods to the Fourier transform for signal analysis, such as the Wavelet transform and the Short-time Fourier transform. These methods offer different advantages and may be more suitable for certain types of signals or applications. It is important to understand the strengths and limitations of each method before choosing the most appropriate one for a particular analysis.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
745
  • Introductory Physics Homework Help
Replies
3
Views
202
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
6
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
18K
Back
Top