Data Fitting
Exercise 2

Running signal_fit.py on the two files gave the following.

In [2]: run signal_fit.py
File name: signal1.txt
Estimated amplitude: 3.0
Estimated frequency: 3.0
Estimated phase: pi/2
A = -3.02254 +/- 0.0452283
f = 3.00334 +/- 0.00277673
phi = 1.69615 +/- 0.114392

In [3]: run signal_fit.py
File name: signal2.txt
Estimated amplitude: 5.0
Estimated frequency: 1.0
Estimated phase: pi/2
A = -3.30928 +/- 0.343876
f = 1.00677 +/- 0.0196462
phi = 1.87478 +/- 0.809695

The output plots are in signal1.pdf and signal2.pdf. Both fits look okay. It may have been difficult to decide good estimates or the parameters given these two plots. In the first case the frequency is relatively high so the plot looks like a scatter plot until you recognize the sinusoidal pattern. In the second case the noise is large compared to the amplitude of the wave again making it difficult to see the sinusoid. There are better ways to analyze sinusoidal signals using Fourier transform techniques.

If you enter poor choices for the parameters you will probably find that the fit is robust against poor choices of phase and amplitude, but is very sensitive to the frequency estimate.