# Math Help - curve fitting

1. ## curve fitting

Hi everybody!

I'm trying to find a function that i could fit to only a few datapoints

x = [10 50 90 100]
y= [0.77 0.75 0.55 0.51]

I have troubles finding a function with only one or two free parameters to fit.
I got stuck with something like:

y(x)= 1 - exp(k*x)

What do you guys think? What would be the best function?

2. ## Re: curve fitting

Assume there is a cubic equation of the form
$f(x) = a_3 x^3 + a_2 x^2 + a_1 x + a_0$

for which

$f(10) = a_3 (10)^3 + a_2 (10)^2 + a_1 (10) + a_0$
$f(50) = a_3 (50)^3 + a_2 (50)^2 + a_1 (50) + a_0$
$f(90) = a_3 (90)^3 + a_2 (90)^2 + a_1 (90) + a_0$
$f(100) = a_3 (100)^3 + a_2 (100)^2 + a_1 (100) + a_0$

Since you know f(10), f(50), f(90), f(100), this equals solving a matrix

$\begin{bmatrix} 10^3 && 10^2 && 10 && 1 \\ 50^3 && 50^2 && 50 && 1 \\ 90^3 && 90^2 && 90 && 1 \\ 100^3 && 100^2 && 100 && 1 \end{bmatrix}$ $\begin{bmatrix} a_3 \\ a_2 \\ a_1 \\ a_0 \end{bmatrix}$= $\begin{bmatrix} .77 \\ .75 \\ .55 \\ .51 \end{bmatrix}$

So, solving that, i got a polynomial

$f(x) = .000000847 x^3 + -.000183 x^2 + 0.007873611111111113 x^1 + 0.7087500000000001$

You can verify, it fits the points perfectly.

3. ## Re: curve fitting

You could try a graphical approach.

Rewrite your equation as 1-y = exp(kx) and take logs.

That gets you ln(1-y) = kx which can be rewritten as Y=kx, where Y=ln(1-y).

If you now plot Y against x you should get a straight line. If the points do lie roughly along a straight line, (which should pass through the origin), then OK., and the slope of the line will be the value of k. If they don't then your equation doesn't work and it's back to the drawing board. Try something else.

The problem with the cubic in the last response is that it will have two turning points and these, (I haven't checked for this case) usually fall within the data points. The curve may well pass throught the data points but it can hardly be said to give a smooth (predictive) representation of the data.

4. ## Re: curve fitting

Hi bottlerocket66!

With so few points and without any information about the expected relation, the best curve is a straight line.
That is the simplest shape that makes no assumptions.
Anything else is just obscuring whatever it is for.

What is it for?

5. ## Re: curve fitting

Hi ILikeSerena!

Thanks for your reply. The data points are from a simple economic choice experiment.
They indicate how the value of a good is discounted. 1 being the value of the good. 0.77 means that it has decreased in value by that factor.
I'm looking for a function that takes into account the curvature and it should be a monotonically decreasing function.
The fitted free parameter(s) of the function should then say something about the individual degree of discounting (amount of curvature).

6. ## Re: curve fitting

These are some other datapoints
x = [10 50 90 100]
y= [0.7700 0.7500 0.6000 0.5000]

7. ## Re: curve fitting

Originally Posted by bottlerocket66
Hi ILikeSerena!

Thanks for your reply. The data points are from a simple economic choice experiment.
They indicate how the value of a good is discounted. 1 being the value of the good. 0.77 means that it has decreased in value by that factor.
I'm looking for a function that takes into account the curvature and it should be a monotonically decreasing function.
The fitted free parameter(s) of the function should then say something about the individual degree of discounting (amount of curvature).
For the way a good is discounted, I would expect a relation like $y=y_0 e^{- x / \tau}$, where $\tau$ is the so called characteristic time, and $y_0$ is the value at x=0.

Looking at your data, that does not seem to match.
Just to mention a couple of other possible relationships:

$y=y_0 e^{- (x / \tau)^2}$

$y=\frac {y_0} { (x / \tau)^2 + 1}$

With both of these relations you can get a pretty good match.