1
$\begingroup$

I need to find a function that smoothly interpolates between a start value and end value in a given range. The following example illustrates the problem.

$\text{range: } r = 22 \\ \text{start: } s= 5 \\ \text{end: } e= 2 \\ \text{steps: } t= \frac{2r}{s+e}= 6.286 \approx 7$

Step values must be rounded up natural numbers. The minimum range must be greater than the sum of the start and end value.
I tried to adapt the compound interest rate equation, which would give me a consistent rate of grows, without success. Either the start or the end value does not match up. I only managed to get a list by a trial and error manipulation of the compound factor but how do I get the function for it?
[5, 8.66, 12, 15, 17.66, 20, 22]
set of points
graph

$\endgroup$
5
  • $\begingroup$ I think I am missing something, but just a basic line will do this nicely. Where are you having trouble? The line would have slope $m = (e-s)/t$. Intercept is $s$. $\endgroup$ Commented Apr 28, 2019 at 1:00
  • $\begingroup$ Ah, I understand, I think. You already have a set of points, and you want to fit a curve, is that right? $\endgroup$ Commented Apr 28, 2019 at 1:05
  • $\begingroup$ Exactly, the curve changes depending on the start and end value as well as the overall range (or length if you will). If I change the start value to, say, 8 and the end value to 1.6 the curve becomes more pronounced. The rise decreases with every step from 8 to 1.6 and it all has to fit into r=20. $\endgroup$
    – Jörg
    Commented Apr 28, 2019 at 1:23
  • $\begingroup$ Where are you getting this data from if not from a function that generates the points? $\endgroup$ Commented Apr 28, 2019 at 1:24
  • $\begingroup$ I simply played around with compound factor on a spreadsheet until I did fit. $\endgroup$
    – Jörg
    Commented Apr 28, 2019 at 1:32

1 Answer 1

0
$\begingroup$

You can get a good fit of your data using, as model, $$y=a+b \,e^{cx}$$

The result would be $$\begin{array}{clclclclc} \text{} & \text{Estimate} & \text{Standard Error} & \text{Confidence Interval} \\ a & +38.7594 & 0.8897 & \{+35.9279,+41.5909\} \\ b & -37.9995 & 0.8105 & \{-40.5788,-35.4203\} \\ c & -0.11733 & 0.0043 & \{-0.13102,-0.10363\} \\ \end{array}$$ which corresponds to $R^2=0.999995$.

Comparing the values $$\left( \begin{array}{ccc} x & y_{exp} & y_{pred} \\ 1 & 5.000 & 4.9666 \\ 2 & 8.667 & 8.7076 \\ 3 & 12.000 &12.0344 \\ 4 & 15.000 & 14.9930 \\ 5 & 17.667 & 17.6240 \\ 6 & 20.000 & 19.9638 \\ 7 & 22.000 &22.0446 \end{array} \right)$$

If you want to exactly match the starting point and the end point, just use $a=38$, $b=-37$ and $c=-0.11825$.

$\endgroup$
1
  • $\begingroup$ I had another look and did a bit of CAD work to visualise the problem. The most feasible way is to connect the start and end values with a Bezier curve and calculate y for each step on the x axis. I'll read up on this in the coming days how to exactly do that. $\endgroup$
    – Jörg
    Commented Apr 28, 2019 at 21:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .