DSPRelated.com
Forums

2nd derivarive of an accumulating signal

Started by Heck June 12, 2007
I'd like to evaluate a series of tuples (amplitude, time) to generate
a single value whose magnitude represents or at least reflects the
rate of change of the rate of change of the amplitude of the tuples.
Second derivative, right?  Only, I don't have the function that
generates this series: I get the tuples in sequence and I have to have
this characteristic nailed down before I received 705 of them.

Can someone suggest how I might achieve this?  What mathematical
relationship can I exploit?  What algorithm might I use?  Perhaps if I
were to iteratively fit a curve to the data.  The curve won't be
pathological at all, but I can't know where or how it will accelerate
or taper off.

I suspect this is a common problem in many applications.  Just point
me into the right area.  Thanks.
On Jun 12, 7:44 pm, Heck <hec...@toodamnmuchspambutreallyverizon.net>
wrote:
> I'd like to evaluate a series of tuples (amplitude, time) to generate > a single value whose magnitude represents or at least reflects the > rate of change of the rate of change of the amplitude of the tuples. > Second derivative, right? Only, I don't have the function that > generates this series: I get the tuples in sequence and I have to have > this characteristic nailed down before I received 705 of them. > > Can someone suggest how I might achieve this? What mathematical > relationship can I exploit? What algorithm might I use?
i s'pose, if your samples are x[n], that supposed to correspond to the bandlimited (to (0.5)/T) function x(t): x(t) = SUM{ x[n] sinc( (t-n*T)/T ) } n and the 2nd derivative would be (d/dt^2)x(t) = SUM{ x[n] (d/dt^2)sinc( (t-n*T)/T ) } n whatever that comes out to be. i'll bet, when (d/dt^2)x(t) is evaluated at t=k*T (integer k), then this 2nd derivative is pretty close to | (d/dt^2)x(t)| = ( (x[k+1]-x[k])/T - (x[k]-x[k-1])/T )/T |t=k*T r b-j
On Jun 12, 9:27 pm, robert bristow-johnson <r...@audioimagination.com>
wrote:
> On Jun 12, 7:44 pm, Heck <hec...@toodamnmuchspambutreallyverizon.net> > wrote: > > > I'd like to evaluate a series of tuples (amplitude, time) to generate > > a single value whose magnitude represents or at least reflects the > > rate of change of the rate of change of the amplitude of the tuples. > > Second derivative, right? Only, I don't have the function that > > generates this series: I get the tuples in sequence and I have to have > > this characteristic nailed down before I received 705 of them. > > > Can someone suggest how I might achieve this? What mathematical > > relationship can I exploit? What algorithm might I use? > > i s'pose, if your samples are x[n], that supposed to correspond to the > bandlimited (to (0.5)/T) function x(t): > > x(t) = SUM{ x[n] sinc( (t-n*T)/T ) } > n > > and the 2nd derivative would be > > (d/dt^2)x(t) = SUM{ x[n] (d/dt^2)sinc( (t-n*T)/T ) } > n > > whatever that comes out to be. i'll bet, when (d/dt^2)x(t) is > evaluated at t=k*T (integer k), then this 2nd derivative is pretty > close to > > | > (d/dt^2)x(t)| = ( (x[k+1]-x[k])/T - (x[k]-x[k-1])/T )/T > |t=k*T > > r b-j
Look at eqn 11 here http://www.claysturner.com/dsp/DSPinterpolation.pdf Clay
"Heck" schrieb
> I'd like to evaluate a series of tuples (amplitude, time) to
generate
> a single value whose magnitude represents or at least reflects the > rate of change of the rate of change of the amplitude of the
tuples.
> Second derivative, right? Only, I don't have the function that > generates this series: I get the tuples in sequence [...]
This is called numerical differentiation. Books can give you formulas, mine [*] gives: f''(x) = (f(x+h)-2f(x)+f(x-h))/h^2 (with three points f(x-h), f(x), f(x+h)) or f''(x) = (-f(x+2h)+16f(x+h)-30f(x)+16f(x-h)-f(x-2h))/h^2 with 4 points. Beware that measured data tend to fluctuate, differentiation is like a highpass filter that accentuates these fluctuations. You might want to low-pass filter your data first. OTOH this might give you wrong results if you expect your acceleration in the high frequency range. [*] H.St&#4294967295;cker, Taschenbuch mathematischer Formeln und moderner Verfahren, Verlag Harri Deutsch
> [...] and I have to have > this characteristic nailed down before I received 705 of them. > [...]
Err, this characteristic is likely to change at every sample, you know that? And as they tell you in banking, "past performance is no guarantee for future performance" :-) You want to have a "single value that respresents" the 2nd derivative?
> Can someone suggest how I might achieve this? What mathematical > relationship can I exploit? What algorithm might I use? Perhaps
if I
> were to iteratively fit a curve to the data. The curve won't be > pathological at all, but I can't know where or how it will
accelerate
> or taper off. >
If you can wait for 705 sample (and a wee bit of compuatation time) and you know that you can fit your data to a known mathematical formula (albeit with unknown parameters) you can define this formula and let gnuplot fit the data and compute the parameters, e.g. f(x)=a*log(d*x+b)+c fit f(x) "exp.dat" via a,b,c,d Beware that this: - might take a long time - the fit might be bad But from then on you can analytically compute the 2nd derivative at any point.
> > I suspect this is a common problem in many applications. Just
point
> me into the right area. Thanks. >
In the hope that the above helps ... Martin
On Jun 13, 1:42 pm, Clay <phys...@bellsouth.net> wrote:
> On Jun 12, 9:27 pm, robert bristow-johnson <r...@audioimagination.com> > wrote: > > > > > On Jun 12, 7:44 pm, Heck <hec...@toodamnmuchspambutreallyverizon.net> > > wrote: > > > > I'd like to evaluate a series of tuples (amplitude, time) to generate > > > a single value whose magnitude represents or at least reflects the > > > rate of change of the rate of change of the amplitude of the tuples. > > > Second derivative, right? Only, I don't have the function that > > > generates this series: I get the tuples in sequence and I have to have > > > this characteristic nailed down before I received 705 of them. > > > > Can someone suggest how I might achieve this? What mathematical > > > relationship can I exploit? What algorithm might I use? > > > i s'pose, if your samples are x[n], that supposed to correspond to the > > bandlimited (to (0.5)/T) function x(t): > > > x(t) = SUM{ x[n] sinc( (t-n*T)/T ) } > > n > > > and the 2nd derivative would be > > > (d/dt^2)x(t) = SUM{ x[n] (d/dt^2)sinc( (t-n*T)/T ) } > > n > > > whatever that comes out to be. i'll bet, when (d/dt^2)x(t) is > > evaluated at t=k*T (integer k), then this 2nd derivative is pretty > > close to > > > | > > (d/dt^2)x(t)| = ( (x[k+1]-x[k])/T - (x[k]-x[k-1])/T )/T > > |t=k*T > > > r b-j > > Look at eqn 11 herehttp://www.claysturner.com/dsp/DSPinterpolation.pdf
okay, let's set T=1 with no loss of generality. is x[k-1] - 2*x[k] + x[k+1] about the same as 2*x[k-1] - ((pi^2)/3)*x[k] + 2*x[k+1] it sure seems to me that there is a difference in scaling. and i'm bothered by this. it sure seems to me that if the signal is way bandlimited (or way oversampled), that the naive derivative (represented as finite differences) must be pretty accurate because your sample time is closer to a differential amount of time. did i get off by a factor of 2? so Clay, can you explain this? (and while you're at it, please explain why i'm wrong about the N even case regarding Bandlimited Interpolation of discrete Periodic sequences?) r b-j
On Jun 13, 3:50 pm, robert bristow-johnson <r...@audioimagination.com>
wrote:
> On Jun 13, 1:42 pm, Clay <phys...@bellsouth.net> wrote: > > > > > > > On Jun 12, 9:27 pm, robert bristow-johnson <r...@audioimagination.com> > > wrote: > > > > On Jun 12, 7:44 pm, Heck <hec...@toodamnmuchspambutreallyverizon.net> > > > wrote: > > > > > I'd like to evaluate a series of tuples (amplitude, time) to generate > > > > a single value whose magnitude represents or at least reflects the > > > > rate of change of the rate of change of the amplitude of the tuples. > > > > Second derivative, right? Only, I don't have the function that > > > > generates this series: I get the tuples in sequence and I have to have > > > > this characteristic nailed down before I received 705 of them. > > > > > Can someone suggest how I might achieve this? What mathematical > > > > relationship can I exploit? What algorithm might I use? > > > > i s'pose, if your samples are x[n], that supposed to correspond to the > > > bandlimited (to (0.5)/T) function x(t): > > > > x(t) = SUM{ x[n] sinc( (t-n*T)/T ) } > > > n > > > > and the 2nd derivative would be > > > > (d/dt^2)x(t) = SUM{ x[n] (d/dt^2)sinc( (t-n*T)/T ) } > > > n > > > > whatever that comes out to be. i'll bet, when (d/dt^2)x(t) is > > > evaluated at t=k*T (integer k), then this 2nd derivative is pretty > > > close to > > > > | > > > (d/dt^2)x(t)| = ( (x[k+1]-x[k])/T - (x[k]-x[k-1])/T )/T > > > |t=k*T > > > > r b-j > > > Look at eqn 11 herehttp://www.claysturner.com/dsp/DSPinterpolation.pdf > > okay, let's set T=1 with no loss of generality. > > is > > x[k-1] - 2*x[k] + x[k+1] > > about the same as > > 2*x[k-1] - ((pi^2)/3)*x[k] + 2*x[k+1] > > it sure seems to me that there is a difference in scaling. and i'm > bothered by this. it sure seems to me that if the signal is way > bandlimited (or way oversampled), that the naive derivative > (represented as finite differences) must be pretty accurate because > your sample time is closer to a differential amount of time. did i > get off by a factor of 2? > > so Clay, can you explain this? (and while you're at it, please > explain why i'm wrong about the N even case regarding Bandlimited > Interpolation of discrete Periodic sequences?) > > r b-j- Hide quoted text - > > - Show quoted text -
Hello Robert, The equations in my paper of course connect the dots with sync functions. And in part they trade rapidity of convergence for trying to work up to 1/2 the sampling rate. If a kernal other than sync is used (for example a raised cosine) the convergence may be sped up. The case you are working towards is basically a polynomial fit. So for low order expansions (like just 3 terms) the two expressions (yours and mine) will differ. In the limit of a large number of terms they will become similar. That paper was written for a case where I only needed the 1st and 2nd derivatives for a single point and I had 5000 terms to work with the the spectrum was filled to just about 1/2 the sampling rate. So I was stuck with a not so great a method, but in the end it worked out and the customer was happy with it. Clay p.s. I'm not sure what you mean by the "N even case"
Martin Blume! 
>"Heck" schrieb
snip
>This is called numerical differentiation.
>Books can give you formulas, mine [*] gives: > >f''(x) = (f(x+h)-2f(x)+f(x-h))/h^2 >(with three points f(x-h), f(x), f(x+h)) > >or > >f''(x) = (-f(x+2h)+16f(x+h)-30f(x)+16f(x-h)-f(x-2h))/h^2 >with 4 points. > >Beware that measured data tend to fluctuate, differentiation >is like a highpass filter that accentuates these fluctuations. >You might want to low-pass filter your data first. OTOH this >might give you wrong results if you expect your acceleration >in the high frequency range. > >[*] H.St&#4294967295;cker, Taschenbuch mathematischer Formeln und moderner > Verfahren, Verlag Harri Deutsch > > >> [...] and I have to have >> this characteristic nailed down before I received 705 of them.
I mistyped. I meant to say 70%.
>> [...] >Err, this characteristic is likely to change at every sample, >you know that? And as they tell you in banking, "past performance >is no guarantee for future performance" :-) >You want to have a "single value that respresents" the 2nd >derivative? > >> Can someone suggest how I might achieve this? What mathematical >> relationship can I exploit? What algorithm might I use? Perhaps >if I >> were to iteratively fit a curve to the data. The curve won't be >> pathological at all, but I can't know where or how it will >accelerate >> or taper off. >> >If you can wait for 705 sample (and a wee bit of compuatation time) >and you know that you can fit your data to a known mathematical >formula (albeit with unknown parameters) you can define this formula >and let gnuplot fit the data and compute the parameters, e.g. >f(x)=a*log(d*x+b)+c >fit f(x) "exp.dat" via a,b,c,d >Beware that this: >- might take a long time >- the fit might be bad >But from then on you can analytically compute the 2nd derivative at >any point. > >> >> I suspect this is a common problem in many applications. Just >point >> me into the right area. Thanks. >> > >In the hope that the above helps ... >Martin
Thanks very much to you and to the others who answered. Numerical differentiation is the term I need, I think. The formulae you cited seem to fit the bill. They look like the simple definition of derivatives, the difference between a measured point and an infinitesimally larger or smaller neighbor. Thank you in particular for the warnings about the potential volatility and inconsistency of the samples and, consequently, the need and the danger, the advantage versus the liability, of filtering the samples.
Thank you both very much for your assistance.  Finite differences,
numerical differentiation, these are the key words I need.

Robert, your citation of ( (x[k+1]-x[k])/T - (x[k]-x[k-1])/T )/T seems
to accomplish what I was imagining but wasn't able to articulate.
Thanks, Clay, for broadening and honing the discussion.

Harold Eckstein


>On Jun 13, 3:50 pm, robert bristow-johnson <r...@audioimagination.com> >wrote: >> On Jun 13, 1:42 pm, Clay <phys...@bellsouth.net> wrote: >> >> >> >> >> >> > On Jun 12, 9:27 pm, robert bristow-johnson <r...@audioimagination.com> >> > wrote: >> >> > > On Jun 12, 7:44 pm, Heck <hec...@toodamnmuchspambutreallyverizon.net> >> > > wrote: >> >> > > > I'd like to evaluate a series of tuples (amplitude, time) to generate >> > > > a single value whose magnitude represents or at least reflects the >> > > > rate of change of the rate of change of the amplitude of the tuples. >> > > > Second derivative, right? Only, I don't have the function that >> > > > generates this series: I get the tuples in sequence and I have to have >> > > > this characteristic nailed down before I received 705 of them. >> >> > > > Can someone suggest how I might achieve this? What mathematical >> > > > relationship can I exploit? What algorithm might I use? >> >> > > i s'pose, if your samples are x[n], that supposed to correspond to the >> > > bandlimited (to (0.5)/T) function x(t): >> >> > > x(t) = SUM{ x[n] sinc( (t-n*T)/T ) } >> > > n >> >> > > and the 2nd derivative would be >> >> > > (d/dt^2)x(t) = SUM{ x[n] (d/dt^2)sinc( (t-n*T)/T ) } >> > > n >> >> > > whatever that comes out to be. i'll bet, when (d/dt^2)x(t) is >> > > evaluated at t=k*T (integer k), then this 2nd derivative is pretty >> > > close to >> >> > > | >> > > (d/dt^2)x(t)| = ( (x[k+1]-x[k])/T - (x[k]-x[k-1])/T )/T >> > > |t=k*T >> >> > > r b-j >> >> > Look at eqn 11 herehttp://www.claysturner.com/dsp/DSPinterpolation.pdf >> >> okay, let's set T=1 with no loss of generality. >> >> is >> >> x[k-1] - 2*x[k] + x[k+1] >> >> about the same as >> >> 2*x[k-1] - ((pi^2)/3)*x[k] + 2*x[k+1] >> >> it sure seems to me that there is a difference in scaling. and i'm >> bothered by this. it sure seems to me that if the signal is way >> bandlimited (or way oversampled), that the naive derivative >> (represented as finite differences) must be pretty accurate because >> your sample time is closer to a differential amount of time. did i >> get off by a factor of 2? >> >> so Clay, can you explain this? (and while you're at it, please >> explain why i'm wrong about the N even case regarding Bandlimited >> Interpolation of discrete Periodic sequences?) >> >> r b-j- Hide quoted text - >> >> - Show quoted text - > >Hello Robert, > >The equations in my paper of course connect the dots with sync >functions. And in part they trade rapidity of convergence for trying >to work up to 1/2 the sampling rate. If a kernal other than sync is >used (for example a raised cosine) the convergence may be sped up. The >case you are working towards is basically a polynomial fit. So for low >order expansions (like just 3 terms) the two expressions (yours and >mine) will differ. In the limit of a large number of terms they will >become similar. That paper was written for a case where I only needed >the 1st and 2nd derivatives for a single point and I had 5000 terms to >work with the the spectrum was filled to just about 1/2 the sampling >rate. So I was stuck with a not so great a method, but in the end it >worked out and the customer was happy with it. > >Clay > >p.s. I'm not sure what you mean by the "N even case" > > >
>On Jun 12, 9:27 pm, robert bristow-johnson <r...@audioimagination.com> >wrote: >> On Jun 12, 7:44 pm, Heck <hec...@toodamnmuchspambutreallyverizon.net> >> wrote:
snip
>Look at eqn 11 here http://www.claysturner.com/dsp/DSPinterpolation.pdf
This is much more than I hoped, an approach to a closed form for my empirically isolated vectors and their members. Harold
On Jun 13, 9:46 pm, Clay <phys...@bellsouth.net> wrote:
> On Jun 13, 3:50 pm, robert bristow-johnson <r...@audioimagination.com> > wrote: > > > > > On Jun 13, 1:42 pm, Clay <phys...@bellsouth.net> wrote: > > > > On Jun 12, 9:27 pm, robert bristow-johnson <r...@audioimagination.com> > > > wrote: > > > > > On Jun 12, 7:44 pm, Heck <hec...@toodamnmuchspambutreallyverizon.net> > > > > wrote: > > > > > > I'd like to evaluate a series of tuples (amplitude, time) to generate > > > > > a single value whose magnitude represents or at least reflects the > > > > > rate of change of the rate of change of the amplitude of the tuples. > > > > > Second derivative, right? Only, I don't have the function that > > > > > generates this series: I get the tuples in sequence and I have to have > > > > > this characteristic nailed down before I received 705 of them. > > > > > > Can someone suggest how I might achieve this? What mathematical > > > > > relationship can I exploit? What algorithm might I use? > > > > > i s'pose, if your samples are x[n], that supposed to correspond to the > > > > bandlimited (to (0.5)/T) function x(t): > > > > > x(t) = SUM{ x[n] sinc( (t-n*T)/T ) } > > > > n > > > > > and the 2nd derivative would be > > > > > (d/dt^2)x(t) = SUM{ x[n] (d/dt^2)sinc( (t-n*T)/T ) } > > > > n > > > > > whatever that comes out to be. i'll bet, when (d/dt^2)x(t) is > > > > evaluated at t=k*T (integer k), then this 2nd derivative is pretty > > > > close to > > > > > | > > > > (d/dt^2)x(t)| = ( (x[k+1]-x[k])/T - (x[k]-x[k-1])/T )/T > > > > |t=k*T > > > > > r b-j > > > > Look at eqn 11 herehttp://www.claysturner.com/dsp/DSPinterpolation.pdf > > > okay, let's set T=1 with no loss of generality. > > > is > > > x[k-1] - 2*x[k] + x[k+1] > > > about the same as > > > 2*x[k-1] - ((pi^2)/3)*x[k] + 2*x[k+1] > > > it sure seems to me that there is a difference in scaling. and i'm > > bothered by this. it sure seems to me that if the signal is way > > bandlimited (or way oversampled), that the naive derivative > > (represented as finite differences) must be pretty accurate because > > your sample time is closer to a differential amount of time. did i > > get off by a factor of 2? > > > so Clay, can you explain this? (and while you're at it, please > > explain why i'm wrong about the N even case regarding Bandlimited > > Interpolation of discrete Periodic sequences?) > > > r b-j > > > Hello Robert, > > The equations in my paper of course connect the dots with sync > functions. And in part they trade rapidity of convergence for trying > to work up to 1/2 the sampling rate. If a kernal other than sync is > used (for example a raised cosine) the convergence may be sped up. The > case you are working towards is basically a polynomial fit. So for low > order expansions (like just 3 terms) the two expressions (yours and > mine) will differ. In the limit of a large number of terms they will > become similar. That paper was written for a case where I only needed > the 1st and 2nd derivatives for a single point and I had 5000 terms to > work with the the spectrum was filled to just about 1/2 the sampling > rate. So I was stuck with a not so great a method, but in the end it > worked out and the customer was happy with it. > > Clay > > p.s. I'm not sure what you mean by the "N even case"
oh, i was trying to slip in this interpolation of periodic sequences Dirichlet thingie that i alluded to in this thread currently: http://groups.google.com/group/comp.dsp/msg/f0013375e6d51954?hl=en& but goes back a few years further. whether it be a periodic wavetable (like with an NCO or DSS - a real sequence in time) or a periodic spectrum being interpolated, what is the correct formula? (i thought your brains could settle it. maybe we should start a new thread with it.) r b-j