You are on page 1of 4

May 2004

Vol 3 Issue 5

Parabola Approximation For
Peak Determination
There are many applications where
a peak value or the location of a
peak value in time is desired.
Examples of such applications
would include a correlation with an
expected signal, the peak of a FFT
bin, or the peak of a sine wave.
The brute force method would be
to over sample the signal such that
the desired resolution is achieved.
Alternatively, there are other
approaches. The approach shown
here uses a parabola to estimate
the shape of the peak for the
desired signal. This approach is
relatively simple in nature and can
significantly reduce the sampling
requirement.

The approach is to curve fit a
generic parabola to the sampled
data. The resulting peak and time
of the peak will fall out of the curve
fit process. The approach discussed
here uses the three largest
samples in the desired signal as
input to the curve fit algorithm.
Thus, the sampling requirement is
that it must be large enough to
support at least three samples in
the signal peak.

Of course, the more samples to
chose from, the better the
estimate of the peak location and
amplitude.

To perform the curve fit, the
following formula for a parabola is
used

F(x) = a + (x-x
0
)[b + c(x-x
1
)]


If the two first values for x are x
0

and x
1
, the corresponding F(x
n
)
(denoted as y
n
) is


y
0
= a and

y
1
= y
0
+ b( x
1
- x
0
)


Solving for b yields

b = (y
1
- y
0
)/( x
1
- x
0
)

Substituting the values for a and b
into F(x
2
) and solving for c results
in


Now F(x) can be written in terms of
three samples points, (x
0
, y
0
),
(x
1
, y
1
), and (x
2
, y
2
). To help
simplify the equation, let the
values for x correspond to -1, 0,
and 1. In this manner, the location
of the peak on the x-axis is a
fraction of the sample period
May 2004
Vol 3 Issue 5

referenced to the center sample
that contains the largest amplitude.
F(x) becomes


To find where the local maximum
or local minimum of F(x) occurs on
the x-axis, take the derivative of F
(x) with respect to x and set it
equal to zero. The result is



Substituting for x
peak
produces the
peak value


Equations (7) and (8) are used to
estimate the peak of a sampled
arbitrary shape.

To gain insight on how this
algorithm performs, a couple
examples are in order.

Suppose that an FFT is performed
on a signal with rectangular
windowing. A good estimate of the
tone peak and/or the frequency of
the tone are desired. The FFT can
be zero padded to get the desired
interpolation resolution or the
estimates for x
peak
and y
peak
can
be used.

Figure 1 on the previous page
illustrates the application of the
parabola estimation on a sin(x)/x
shaped peak. The actual curve is
shown in red, the three discrete
samples of the peak are shown in
the blue boxes and the estimated
peak is shown with the black circle.
In this example, the actual peak is
(-0.30, 1.77) and the estimated
peak is approximately (-0.28,
1.75).

A second example is a correlation
of a band-limited signal. Suppose
the correlation of a received band
limited signal is the shape of a
raised cosine square pulse:

corr(x) = 0.8*cos
2
(2*pi*(x-0.25))


The resulting estimation for a
sampled version is shown in Figure
2 overleaf. The actual curve is
shown in red, the three discrete
samples of the peak are shown in
the blue boxes and the estimated
peak is shown with the black circle.
In this example, the actual peak is
(0.25, 0.8) and the estimated peak
is approximately (0.24, 0.8).

For a fixed-point implementation of
this estimation, notice that all
May 2004
Vol 3 Issue 5


coefficients are multiples of two.

Implementing the coefficients as
shifts instead of multiplies can
reduce processor loading. An
example implementation for a
sixteen-bit version of the peak
estimator that computes both the
peak value y and the location of
the peak on x is shown in Appendix
1.

The types INT16 and INT32 are
generic 16-bit and 32-bit integer
values. The specific type (short,
int, or long) will be processor
dependent. For a TI TMS3206416
fixed point processor, the average
number of clock cycles for this
function is approximately 175 when
the compiler optimization speed
parameter is set to "Speed Most
Critical and Optimization Level set
to "File in Code Composer Studio
V2.

For just the x location of the peak,
the average number of clock cycles
is approximately 104. For just the y
peak it is approximately 120 clock
cycles. For additional levels of
efficiency, the function can be
converted to assembly code and/or
approximations for the division
(see February 2004 issue of
www.globaldsp.com) can be used.

Thus it can be seen that this
method provides an increased level
of accuracy with a modest amount
of extra processing. This extra
processing is only required when
performing the detailed peak
estimation or location of the peak
estimation. So the next time a
correlation time or peak level is
required, try this algorithm out.
The results may be quite
appealing.

See next page for Appendix 1
(Algorithm Code)

Paul Voglewede is a
Principal Engineer
with Harris RF
Communications
focusing on
communication
digital signal
processing.


May 2004
Vol 3 Issue 5

Appendix 1

Example 16-bit Fixed-Point
Implementation

static void PeakFilt16(INT16* y,
INT16* xPeak, INT16* yPeak)
{
INT32 ly[3];
INT32 num1;
INT32 num2;
INT32 den;
INT32 temp32;

// convert 16 bit input values to
// 32 bits
ly[0] = (INT32)y[0];
ly[1] = (INT32)y[1];
ly[2] = (INT32)y[2];

// calculate the denominator
den = ly[0] + ly[2] - (ly[1]<<1);

/////////////////////////
// generate x and y peak values
/////////////////////////
if(den > 0)
{
// if the denominator is 0, then
// all three values are
// equal. There is no peak,
// so return middle sample.
*xPeak = 0;
*yPeak = y[1];
}
else
{
// compute the numerator for
//the x value. The factor of
// one half is included in
//the shift. A shift of 15 would
// be the normal shift for 16-
//bit math.

num1 = (ly[0] - ly[2])<<14;

// compute the xPeak value
//and cast back into 16 bits

temp32 = num1/den;
if(Abs32(temp32) < 32768)
{
*xPeak = (INT16)temp32;
}
else
{
if(temp32 < 32768)
{
*xPeak = 32767;
}
else
{
*xPeak = -32767;
}
}

// Compute the y peak value.
//Multiply the numerator by
//- 1/16 and then by 2 to achieve
//the -1/8 factor in front of the
// equation.

num1 = ((ly[2]*ly[1])>>1) - ((ly
[0]*ly[0])>>4) - ((ly[2]*ly[2])
>>4);

num2 = ((ly[0]*ly[1])>>1) + ((ly
[0]*ly[2])>>3) - (ly[1]*ly[1]);

num1 += num2;
num1 <<= 1;
temp32 = num1/den;
if(Abs32(temp32) < 32768)
{
*yPeak = (INT16)temp32;
}
else
{
if(temp32 < 32768)
{
*yPeak = 32767;
}
else
{
*yPeak = -32767;
}
}
} // end else den > 0

}

You might also like