I'm looking for a way to derive the equation of a curve that will fit a set of points.
I have a set of points like this:
{130,20},
{150,30},
{160,40},
{165,50},
{175,60},
{185,70},
{192,80},
{200,90},
{205,100},
{210,120},
{215,140}
How can I programmatically derive a formula for this curve? I'm writing software that will have different data for the X values but all data will follow the general shape of the curve.
For more background information, I'm estimating Training Stress Score (Y values) from heart rate (x values). More information on that here: https://www.trainingpeaks.com/blog/estimating-training-stress-score-tss/.
So given a heart rate of 170, it would return a value of 50. However, this should be able to be made more accurate with a curve since a heart rate of 174 should have a TSS value of closer to 60 than 50.
Since I'll be allowing a user to define their own heart rate values (depending on their own personal heart rate zones), the method of finding the curve will need to be derived from those values.
A simple approach which preserves the monotonicity (strict increasing property) of the data is linear interpolation.
In the case you mentioned for a heart rate of $170$, this occurs at the midpoint between the points $(165,50)$ and $(175,60)$. Linear interpolation thus returns the midpoint value of $55$ for heart rate $170$, and for heart rate $174$ we get:
$$ 50 + (174 - 165)\frac{60-50}{175-165} = 59 $$
In general one locates the two data points $(x_0,y_0)$ and $(x_1,y_1)$ which bracket an input value $X$, i.e. $x_0 \lt x \lt x_1$ in ascending order, and we calculate:
$$ y = y_0 + (x - x_0) \frac{y_1 - y_0}{x_1 - x_0} $$