Re: demodulation question

*To*: mathgroup at christensen.cybernetics.net*Subject*: [mg526] Re: [mg514] demodulation question*From*: David Harrison <davidh>*Date*: Thu, 9 Mar 1995 10:18:12 -0600 (CST)

Yves Verbandt wrote: > I have some measured curves which following the model have the following > form : > > s(x) = f(x)*cos(k*x) > > where k is a constant and f(x) is a slowly varying function. Because there > is coniderable noise on the measurements the cosine is not very regular. > Does anyone have an idea how to extract f(x)? I tried the NonlinearFit > package and this was not very successfull! There are a number of related problems here. First, any nonlinear fitter, including the Marquardt algorithm used by NonlinearFit, can easily find some local minimum in the chi-squared and miss the true minimum. Thus, one must almost always provide good initial guesses of parameter values to NonlinearFit. The other related problem is that when there is noise, then two spectra taken from an identical sample with the same instrument can end up fitting to different values of the parameters, even when the initial values given to the fitter are the same. This is motivation for various people bringing out much heavier artillery such as neural networks to try to deal with nonlinear fitting. These efforts are sometimes very succesful, but also very compute intensive. Here are a few things that might be tried in the context of the particular question under consideration. 1. Try smoothing the data to reduce the noise. One simple way to do that is to compute local averages with something like: << Statistics`DescriptiveStatistics` smoothed = Mean /@ Partition[data, some_number, 1] where 'some_number' is a value substantially less than the number of points in 'data'. Note that 'smoothed' contains fewer points than 'data', and loses information at the edges. There also can be systematic effects in a simple-minded procedure like this, particularly around the edges of the data and the extrema of the cosine. 2. Sneak up on the values you want. It isn't totally clear what the parameters are that are being fit to here: s(x) = f(x)*cos(k*x) but presumably k is one of them and another one or more are in the function f. Then fix the parameters in f and find a value for k. Then fix the value of k and fit to one or more parameters in f. Iterate until you are close enough. Always plot the residuals between your fit and the data to look for systematic effects. 3. If 'k' is not one of the parameters to be fit, then try: s(x)/cos(k*x) = f(x) In fact, if you are sneaking up on the values as in #2 above, this can sometimes be useful. Hopefully some of this will be helpful. --- Dr. David Harrison | "Music is a hidden practice of the Visiting Scholar | soul, that does not know it is Wolfram Research Inc. | doing mathematics". -- Leibniz