0

I require a python solution to force a polynomial to end at a specific point. I have read the solutions offered here: How to do a polynomial fit with fixed points to a similar question but have been unable to get any of these methods working on my data set as are not defining end points but locations to for a polynomial to pass through.

I therefore require a solution to force a polynomial curve to end at a specific location.

To put this in context the example that I need this for is shown in the image below, I require a line of best fit for the data below, the green points represent the raw data and the pink points are the mean of the green points for every x value. The best fit should be a 3rd order polynomial until the data becomes a horizontal linear line. The black line is my current attempt at a line of best fit using np.ployfit(), I have defined the polynomial to only plot until the location where I would then start the linear best fit line but as you can see the tail of the polynomial is far to low and hence I want to force it to end / go through a specific point.

I am open to all options to get a nice mathematically sensible best fit as have been banging my head against this problem for too long now.Wind Turbine SCADA Data

Community
  • 1
  • 1
Henry Quekett
  • 429
  • 1
  • 7
  • 16
  • 2
    I didn't down-vote but somebody else has, very likely because this question is outside the scope of stackexchange. Which is for programming questions. You might be better off to post it on 'Cross Validated' or even 'Computational Science' which you can find by looking through the sites at the bottom of this page. Best of luck. – Bill Bell Dec 01 '16 at 22:40
  • What's stopping you from defining a fitting function that is a piecewise function of a polynomial and a constant? – Andras Deak -- Слава Україні Dec 01 '16 at 22:50
  • Sorry, of course you'll need something like `scipy.optimize.curve_fit` rather than `numpy.polyfit` for that. – Andras Deak -- Слава Україні Dec 01 '16 at 23:10
  • @BillBell Thank you I have additionally posted the question on 'Cross Validated'. – Henry Quekett Dec 01 '16 at 23:12
  • I do not understand what problem you have with the answers in the linked question. Polynomials do not have end points. – Stop harming Monica Dec 02 '16 at 09:03
  • Assuming you fit an acceptable equation to these data what would you do with it? – Bill Bell Dec 02 '16 at 17:04
  • @BillBell I intend on using the lines of best fits of multiple turbines to identify poorly performing turbines, additionally because in a wind farm some turbines are in wake I will use a separate model to account for this wake effect and predict how much this will effect the power curve allowing me to make predictions when the wake effect has been eradicated. – Henry Quekett Dec 02 '16 at 17:11

2 Answers2

1

Using a logistic sigmoid instead of a polynomial:

logistic sigmoid data fit

Formula and parameters, generated from some of your sample data points(taken from the picture):

logistic sigmoid fit parameters

where S(x) is the sigmoid function.

Mauro Lacy
  • 389
  • 2
  • 8
0

A distinct approach, since you seem to want to identify outliers in the horizontal dimension.

Stratify your data by power, say into 10-kW intervals, so that each interval contains 'enough' points to use some robust estimator of their dispersion. In each stratum discard upper extreme observations until the robust estimate falls to a stable value. Now use the maximum values for the strata as the criteria against which to gauge whether any given device is to be regarded as 'inefficient'.

Bill Bell
  • 21,021
  • 5
  • 43
  • 58