Re: fitting data to a sampled waveform?
- To: mathgroup at smc.vnet.net
- Subject: [mg23389] Re: [mg23355] fitting data to a sampled waveform?
- From: Carl Woll <carlw at u.washington.edu>
- Date: Fri, 5 May 2000 02:07:26 -0400 (EDT)
- References: <200005040659.CAA17479@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Marrtin, I assume you have data which you want to fit to the function A Sin[t - t0] + B If so, why don't you use the NonlinearFit function in the package Statistics`NonlinearFit`? You can specify the method FindMinimum which will carry out a least squares fit. Carl Woll Martin Rommel wrote: > I have a waveform given as sample data. Then I have another related waveform > which I want to least-square-fit to it. Initially using phaseshift, > amplitude (amplification) and (DC-)offset as fit parameters will do. > > By playing I can manually find offset, phase and amplification easily > (assuming that the moments of the two distributions correspond the offset > is the difference of the means and the amplification is the ratio of the > standard deviation, but I don't think that this amounts to a least square > fit). For the phase one could relate extrema or other easily identifiable > features. As soon as the data get noisy or distorted all that becomes tricky > and ill-defined. > Probably I can use an InterpolatingFunction as model for Fit but that seems > to be a detour since for the actual fit discrete values are calculated. The > advantage would be, however, that I could get a phase with higher accuracy > than the sampling period. I already wrote a simple fractional Rotate for > that allows to phase shift the two waveforms: > > fracRotate[lst_List, d_] := > With[{fp = Abs[FractionalPart[d]] , s = Sign[d]}, > ((1 - fp)RotateRight[lst, s Floor[Abs[d]]] + fp RotateRight[lst, s > Ceiling[Abs[d]] ])]; > > Any comments, references, ideas? > > Martin
- References:
- fitting data to a sampled waveform?
- From: "Martin Rommel" <Martin_Rommel@mac.com>
- fitting data to a sampled waveform?