Henry Quekett
Henry Quekett

Reputation: 429

Python plotting a polynomial with fixed end point

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

Upvotes: 0

Views: 1229

Answers (2)

Mauro Lacy
Mauro Lacy

Reputation: 389

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.

Upvotes: 1

Bill Bell
Bill Bell

Reputation: 21643

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'.

Upvotes: 0

Related Questions