Re: Fitting to a square wave
- To: mathgroup at smc.vnet.net
- Subject: [mg30510] Re: [mg30483] Fitting to a square wave
- From: Yasvir Avindra Tesiram <y.tesiram at pgrad.unimelb.edu.au>
- Date: Fri, 24 Aug 2001 04:06:14 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Hi Urijah, Assuming your data is symmetrical about some point x you could try functions of the form f[x_]:=a * Exp[x^n/2], sort of a modified gaussian. Raising n flattens the distribution to approximate a square distribution. If this proves unsatisfactory then maybe you could try functions of the form that I posted on the Mathgroup [mg30408]. f[x_]:=a * Sech[b * x^n]^2 and 'a' will be the height of the function and 'b' is a truncation factor. Again, the larger the value of n, the "squarer" the distribution. Of course you can change sech to sin or whatever suits and is simplest to deal with. Hope this helps. Yas On Thu, 23 Aug 2001, Urijah Kaplan wrote: > I have a bunch of data that looks like a noisy square wave (more like a > trapazoid actually, with it wider on the bottom) and I've been trying to > find a consistent way to find the hight and width. I first fit a gaussian > using NonlinearFit, but that tended to have its center shift, even if I only > multiplied the raw data by a constant. I tried fitting to an actual square > wave using a step function, but that didn't give me a good result either. > Any ideas? Thanks so much. > > > > --Urijah Kaplan > > > > > >