0
$\begingroup$

I need to predict a function that can satisfy the value pairs given below. \begin{array}{|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|} \hline X & 0.25 & 0.5 & 1 & 2 & 4 & 6 & 8 & 10 & 12 & 14 & 16 & 18 & 20 & 22 & 24 & 26 & 27 \\\hline Y & 3.1 & 3.9 & 4.8 & 6 & 7.35 & 8.2 & 8.65 & 8.75 & 8.4 & 7.75 & 6.9 & 5.9 & 4.8 & 3.8 & 2.9 & 2.5 & 2.42\\\hline \end{array}

I tried plotting $Y$ against $X$, to see the graph shape and got the something like the one in the picture below. enter image description here

How can I come up with a function that fits this curve well?

Thanks in advance!!

$\endgroup$
3
  • 3
    $\begingroup$ The function looks familiar to $f(x)=x\cdot e^{-x}$. So you might choose a function like $h(x)=axe^{-bx+c}+d$ and then maybe use the method of "least squares" en.wikipedia.org/wiki/Least_squares. It depends on your level and what you are familiar with. $\endgroup$
    – Cornman
    Jun 5, 2018 at 7:45
  • $\begingroup$ I would also start with what @Cornman suggests. It might be that it's not possible to analytically solve for all of the coefficients $a,b,c,d$ and you might have to resort to numerically finding them. $\endgroup$
    – Matti P.
    Jun 5, 2018 at 8:10
  • $\begingroup$ Thank you for all your replies, I did mean the reasoning process behind finding an appropriate function. @Cornman 's reply was very useful. $\endgroup$
    – Klariel
    Jun 6, 2018 at 1:17

1 Answer 1

2
$\begingroup$

Using MATLAB's curve fitting tool, I could come up with three models that fit your data.

Rational with a numerator of degree $2$ and denominator of degree $4$

X = [0.25 0.5 1 2 4 6 8 10 12 14 16 18 20 22 24 26 27];
Y = [3.1 3.9 4.8 6 7.35 8.2 8.65 8.75 8.4 7.75 6.9 5.9 4.8 3.8 2.9 2.5 2.42];
f = fit(X', Y', 'Rat24')
plot(f, X, Y);

enter image description here

 General model Rat24:
 f(x) = (p1*x^2 + p2*x + p3) /
           (x^4 + q1*x^3 + q2*x^2 + q3*x + q4)
 Coefficients (with 95% confidence bounds):
   p1 =      -419.6  (-3693, 2854)
   p2 =   5.161e+04  (-9.892e+04, 2.021e+05)
   p3 =   2.061e+04  (-2.659e+04, 6.781e+04)
   q1 =      -3.892  (-69.44, 61.66)
   q2 =        -176  (-1603, 1251)
   q3 =        5884  (-1.367e+04, 2.544e+04)
   q4 =        9203  (-1.284e+04, 3.125e+04)

Sum of Sine with $5$ terms

X = [0.25 0.5 1 2 4 6 8 10 12 14 16 18 20 22 24 26 27];
Y = [3.1 3.9 4.8 6 7.35 8.2 8.65 8.75 8.4 7.75 6.9 5.9 4.8 3.8 2.9 2.5 2.42];
f = fit(X', Y', 'Sin5')
plot(f, X, Y);

enter image description here

 General model Sin5:
 f(x) =  
                a1*sin(b1*x+c1) + a2*sin(b2*x+c2) + a3*sin(b3*x+c3) + 
                a4*sin(b4*x+c4) + a5*sin(b5*x+c5)
 Coefficients (with 95% confidence bounds):
   a1 =       12.32  (-4.495e+04, 4.497e+04)
   b1 =      0.1487  (-151.6, 151.9)
   c1 =     -0.4534  (-3155, 3154)
   a2 =       8.179  (-1.59e+05, 1.59e+05)
   b2 =      0.2882  (-2098, 2098)
   c2 =      0.3671  (-3.106e+04, 3.106e+04)
   a3 =        9.25  (-2.488e+06, 2.488e+06)
   b3 =      0.4346  (-9490, 9491)
   c3 =       1.385  (-1.368e+05, 1.368e+05)
   a4 =     0.09242  (-246.5, 246.7)
   b4 =      0.8063  (-154.5, 156.1)
   c4 =       2.213  (-2339, 2344)
   a5 =       5.857  (-2.692e+06, 2.692e+06)
   b5 =      0.4773  (-7626, 7627)
   c5 =       3.911  (-1.101e+05, 1.101e+05)

Gaussian with $5$ terms

X = [0.25 0.5 1 2 4 6 8 10 12 14 16 18 20 22 24 26 27];
Y = [3.1 3.9 4.8 6 7.35 8.2 8.65 8.75 8.4 7.75 6.9 5.9 4.8 3.8 2.9 2.5 2.42];
f = fit(X', Y', 'Gauss5')
plot(f, X, Y);

enter image description here

 General model Gauss5:
 f(x) = 
          a1*exp(-((x-b1)/c1)^2) + a2*exp(-((x-b2)/c2)^2) + 
          a3*exp(-((x-b3)/c3)^2) + a4*exp(-((x-b4)/c4)^2) + 
          a5*exp(-((x-b5)/c5)^2)
 Coefficients (with 95% confidence bounds):
   a1 =      0.8553  (-148.3, 150)
   b1 =       17.72  (-26.81, 62.25)
   c1 =        4.54  (-132.9, 142)
   a2 =      -368.5  (-1.139e+07, 1.139e+07)
   b2 =      -16.27  (-9.613e+04, 9.609e+04)
   c2 =       7.407  (-2.066e+04, 2.067e+04)
   a3 =       4.209  (-741.8, 750.2)
   b3 =       9.977  (-405.4, 425.3)
   c3 =       8.143  (-798.5, 814.8)
   a4 =       5.467  (-2091, 2102)
   b4 =      -5.272  (-1.018e+04, 1.017e+04)
   c4 =       34.49  (-3662, 3731)
   a5 =  -2.481e+13  (-1.676e+19, 1.676e+19)
   b5 =      -24.46  (-5.5e+05, 5.499e+05)
   c5 =       4.421  (-5.07e+04, 5.071e+04)

I am sure if you play around with the fit function in MATLAB, you can come up with better models.

$\endgroup$

You must log in to answer this question.

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