Re: Moving average / smoothing data
- To: mathgroup at smc.vnet.net
- Subject: [mg64064] Re: [mg64063] Moving average / smoothing data
- From: gardyloo <gardyloo at mail.wsu.edu>
- Date: Tue, 31 Jan 2006 01:14:09 -0500 (EST)
- References: <200601300410.XAA29456@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi, Lea, For a function of the sort you're talking about (not the exponential data; I can send a separate package which might help you out for that), my rough strategy is to: 1. Sample the function (or the data) at a sufficiently high rate so as to not skip over the higher-frequency oscillations; 2. Fourier transform the sampled data, and pick out the largest two peaks, noting their magnitudes and frequencies; 3. Construct a trial function of the form trialFn[x_]:=A*( magnitude1 * Sin[2Pi * frequency1*x] + magnitude2 * Sin[2Pi * frequency2*x] ). Of course, you may want to include arbitrary phase offsets in the arguments to the sine functions; 4. Do a FindFit[ sampledData, trialFn[x], { {A, some guess}, {frequency1, output1 from Fourier transform}, {frequency2, output2 from Fourier transform} }, x]; 5. Extract the parameters! I've tried this on the form of the function you use (quoted below), and it looks to work quite well. I'll try to send along some actual code soon. Best of luck, Curtis O. Lea Rebanks wrote: >Hi All, > >Given the following function & subsequent plot. > >tt={1.5*Sin[x]+0.5*Sin[20*x],1.5*Sin[x]}; >pp=Plot[Evaluate[tt],{x,0,20}]; > > >I am trying to get the best smoothing / moving average function closest >to the underlying 1.5*sin[x] > >Has anyone got any suggestions? Please show coding in reply so I can >plot & see result. > >I have similar noise on exponential data, so hopefully >the moving average you recommend will work on that too. > >Many thanks for your attention. > >Lea Rebanks... > >PS I am using version 5.1 > > > > >
- References:
- Moving average / smoothing data
- From: "Lea Rebanks" <lrebanks@netvigator.com>
- Moving average / smoothing data