Curve extrapolation: polynomial or Bézier?

In summary, the conversation discussed using a smooth causal filter to calculate a stationary, non-periodic signal. The filter is sampled discretely and the goal is to find the "path" the signal is traveling on in order to extrapolate its current shape until it reaches a maximum/minimum point. The conversation then explored using a Geogebra script for a Bézier curve with added restrictions on the control points in order to visualize the movement and predict where it would end up. The idea of using polynomials or orthogonal polynomials was also brought up, but it was suggested that a FFT of the data may be a better approach. The conversation then discussed the issue of using FFT for online analysis and the potential of using a linear chirp model
  • #1
MisterH
12
0
On a stationary, non-periodic signal (black) a smooth causal filter is calculated (green/red). It is sampled discretely (every distance unit of 1 on the X-axis). My goal is to find which "path" it is "travelling" on so I can extrapolate the current shape until it is completed (reaches a maximum/minimum: 1st derivative = 0), in real time: so at every point in time I assume the shape of the completed "path" and I want to measure the length between the previous turning point and the extrapolated turning point of this extrapolated curve:

extrapolate via bézier.jpg

I was playing around with a Geogebra script of a Bézier curve because dragging around the control points is visual and intuitive (for non-math guys like me) and it is easy to see where my current smooth movement would end if it were to continue "on the same path" it is currently on. I added some restrictions to my control polygon of my Bézier curve: 2 consecutive control points can only be on horizontal or vertical lines. In case of the image above, I used a Bézier curve of order 5, so it has 6 control points with the following restrictions:
  • A & B are on a horizontal line
  • B & C are on a vertical line
  • C & D are on a horizontal line
  • D & E are on a vertical line
  • E & F are on a horizontal line
So under these restrictions, at the blue arrow we assume the curve will continue via the dotted line to point F: so we start fitting the data from point A (the previous turning point) up to the blue arrow (a bit after the last turning point), and "extrapolate" further to F.

extrapolation complete.jpg


But then I realized that I don't need a parametric curve: I don't need an element of "speed" along the path (and all the headache that comes with that). I need something more simple. Should I just fit a polynomial

ax^5+bx^4+cx^3+dx^2+ex+f = 0

and then calculate where the slope of the tangent becomes 0 for points to the right of my blue arrow (to mimic that last control point F)? Or should I use a Bernstein polynomial to keep the same shape-properties as the Bézier, knowing that I only need y=f(x).
 
Mathematics news on Phys.org
  • #2
The first question that comes to my mind is to ask why you think that past history has any influence on the turning point (max or min) in the future? I certainly don't see any pattern. Some time series analysis might help to identify any relationship that would help you make a predictor. If time series analysis does not show a relationship, I think you may just be fooling yourself to make a predictor.
 
Last edited:
  • #3
My goal is not to use this signal as a predictor on itself: the data is only stationary, not periodic. I try to get an estimate for the instantaneous frequency of the smooth curve. This I can further use as an input for other filters and models that are calculated on the original signal so I can make those adaptive. Instead of using a look-back window of constant length, I change it dynamically. When the extrapolated turning-point lies further to the right of the last observation, I make the look-back window longer, if the extrapolated turning-point is at a short distance, my window length (of the other models) decreases.
 
  • #4
  1. Using polynomials is not recommended. Even if they fit your data points, they tend to oscillate wildly in between.
  2. There are several families of orthogonal polynomials that are much better at approximation.
  3. My personal favorite: Do a FFT of your data, throw away some of the highest frequencies and convert back.
 
  • Like
Likes MisterH
  • #5
Svein said:
Using polynomials is not recommended. Even if they fit your data points, they tend to oscillate wildly in between.

Yes, probably related to Runge's[/PLAIN] Phenomenon?

Svein said:
My personal favorite: Do a FFT of your data, throw away some of the highest frequencies and convert back.

I am afraid that for online analysis, the FFT suffers from edge effect.

Something else I had in mind was this: the linearly swept sine / chirp: ( a sinusoidal wave that increases in frequency linearly over time):
Let me post some R-code of a linear chirp:
Code:
a<-1/100
b<-1/200
c<-1 #amplitude 1
d<-4
x<-1:80
output<-c*sin((pi/(b-a))*(((((x/d)*(b-a))+a)^2)-(a^2)))
plot(output,type="l",pch=20,lwd=3,col='orange',main="Chirp / Linearly Swept Sine & Bézier of order 5")

If I draw my Bézier curve of order 5 with the known restrictions on top of the linear chirp (from the first to the second to the last turning point), I see that they are equal: it is done manually, so there is some error on the estimation of the control points:

upload_2015-5-3_11-3-54.png


Maybe I could use the model of the linear chirp for the regression & extrapolation?
The code for the blue curve (Bézier curve of order 5) is this:
Code:
cpx<-c(8,40,40,65,65,78)
cpy<-c(output[8],output[8],-1.85,-1.85,output[78],output[78])

t<-seq(0,1,len=101)
P0<-matrix(data=c(cpx[1],cpy[1]),nrow=1,ncol=2,byrow=FALSE,dimnames=NULL)
P1<-matrix(data=c(cpx[2],cpy[2]),nrow=1,ncol=2,byrow=FALSE,dimnames=NULL)
P2<-matrix(data=c(cpx[3],cpy[3]),nrow=1,ncol=2,byrow=FALSE,dimnames=NULL)
P3<-matrix(data=c(cpx[4],cpy[4]),nrow=1,ncol=2,byrow=FALSE,dimnames=NULL)
P4<-matrix(data=c(cpx[5],cpy[5]),nrow=1,ncol=2,byrow=FALSE,dimnames=NULL)
P5<-matrix(data=c(cpx[6],cpy[6]),nrow=1,ncol=2,byrow=FALSE,dimnames=NULL)
par(mfrow=c(1,1),mar=c(2,2,2,0))
B<-(1-t)^5%*%P0+5*((1-t)^4)*t%*%P1+10*t^2*(1-t)^3%*%P2+10*(1-t)^2*t^3%*%P3+5*(1-t)*t^4%*%P4+t^5%*%P5
# plot(0,col="red",pch=20,type="n",xlim=c((min(cpx)-10),(max(cpx)+10)),ylim=c((min(cpy)-10),(max(cpy)+10)),main="Bézier Curve of 5th order")
plot(output,type="l",pch=20,lwd=3,col='orange',main="Chirp / Linearly Swept Sine & Bézier of order 5",ylim=c(-2,2));abline(h=0,lty=3)
lines(B,col='deepskyblue',lwd=3,lty=2)
points(P0,pch=20,col='deepskyblue');points(P1,pch=20,col='deepskyblue');points(P2,pch=20,col='deepskyblue');points(P3,pch=20,col='deepskyblue');points(P4,pch=20,col='deepskyblue');points(P5,pch=20,col='deepskyblue');text(cpx[1],cpy[1],"P0",cex=.8,pos=1,col='deepskyblue');text(cpx[2],cpy[2],"P1",cex=.8,pos=1,col='deepskyblue');text(cpx[3],cpy[3],"P2",cex=.8,pos=2,col='deepskyblue');text(cpx[4],cpy[4],"P3",cex=.8,pos=4,col='deepskyblue');text(cpx[5],cpy[5],"P4",cex=.8,pos=1,col='deepskyblue');text(cpx[6],cpy[6],"P5",cex=.8,pos=1,col='deepskyblue');segments(cpx[1],cpy[1],cpx[2],cpy[2],lty=3,col='deepskyblue');segments(cpx[2],cpy[2],cpx[3],cpy[3],lty=3,col='deepskyblue');segments(cpx[3],cpy[3],cpx[4],cpy[4],lty=3,col='deepskyblue');segments(cpx[4],cpy[4],cpx[5],cpy[5],lty=3,col='deepskyblue');segments(cpx[5],cpy[5],cpx[6],cpy[6],lty=3,col='deepskyblue')
 
Last edited by a moderator:
  • #6
MisterH said:
I am afraid that for online analysis, the FFT suffers from edge effect.
Forgot to say, do a linear regression first and subtract that line. Then add it back at the end.
 
  • Like
Likes MisterH
  • #7
MisterH said:
so I can extrapolate the current shape ... the extrapolated turning point of this extrapolated curve:
Are you sure you are not using this as a predictor?
 
  • #8
FactChecker said:
Are you sure you are not using this as a predictor?

I confess! :smile: I guess that I want to use it as an indirect predictor: a predictor for the length of the look-back window of another filter. Whether that is prediction or not is debatable/semantics. In my opinion trying to find the instantaneous frequency of a smooth curve by some extrapolation method is not really about prediction (which is about the future), but more about estimating the state/regime of the present.
 
  • #9
MisterH said:
more about estimating the state/regime of the present.
I understand now. I agree.
 

1. What is curve extrapolation?

Curve extrapolation is a method used to extend a curve beyond its existing data points in order to make predictions about its future behavior. It is commonly used in data analysis and modeling to estimate values outside of the range of observed data.

2. What is the difference between polynomial and Bézier curve extrapolation?

Polynomial curve extrapolation involves using a mathematical function to generate a curve that best fits the existing data points. Bézier curve extrapolation, on the other hand, uses a series of control points to define the shape of the curve. While polynomial extrapolation can produce a smooth curve, Bézier extrapolation allows for more precise control over the shape of the curve.

3. Which method is more accurate for curve extrapolation?

The accuracy of curve extrapolation depends on the specific data and the assumptions made during the extrapolation process. In some cases, polynomial extrapolation may be more accurate, while in others, Bézier extrapolation may be a better fit. It is important to carefully consider the data and the underlying assumptions before deciding which method to use.

4. Can curve extrapolation be used for any type of data?

Curve extrapolation can be used for a wide range of data, including numerical, categorical, and time series data. However, the accuracy and validity of the results will depend on the nature of the data and the assumptions made during the extrapolation process.

5. What are the limitations of curve extrapolation?

Curve extrapolation is based on making assumptions about the behavior of a curve beyond the observed data points. Therefore, it is important to carefully consider the data and the underlying assumptions, as extrapolation can lead to inaccurate or misleading results if these assumptions are not valid. Additionally, extrapolation should be used with caution when making predictions far into the future, as the accuracy of the extrapolated curve may decrease over time.

Similar threads

Replies
1
Views
3K
  • General Math
Replies
2
Views
2K
  • Classical Physics
2
Replies
39
Views
3K
Replies
4
Views
2K
Replies
1
Views
795
  • Calculus and Beyond Homework Help
Replies
6
Views
147
  • General Math
Replies
5
Views
2K
Replies
14
Views
3K
Replies
2
Views
5K
Replies
3
Views
1K
Back
Top