1
$\begingroup$

I know this has been asked a few times before, but I'm struggling to apply it to my scenario...

I have some known values in a table: $$ \begin{array}{|c|c|} \hline \text{Degrees} & \text{Percent} \\ \hline 5 & 9.0949720917 \\ 10 & 9.788059925 \\ 15 & 10.4054090336 \\ 20 & 10.9435666945 \\ 25 & 11.3984372031 \\ 30 & 11.7665587215 \\ 35 & 12.045129627 \\ 40 & 12.2320298195 \\ 45 & 12.325836884 \\ \hline \end{array} $$

I'd like to be able to calculate any percentage between 0 and 45 degrees. So I used the following formula:

$$ y(t)= a X e^{kt} $$

$$ 12.325836884 = 9.0949720917 X e ^{45k} $$

Solve k:

$$ 1.355236361 = e ^ {45k} $$

Take natural log:

$$ ln(1.355236361) = 45k $$

Rearrang:

$$ k = ln(1.355236361)/45 $$

So, to check to see if the calculation holds at 20 degrees:

$$ y(20) = 9.0949720917 e ^ {(ln(1.355236361)/45) 20} = 10.4106 $$

Which is incorrect...

I'd be very grateful if someone could point out the failure in my feeble attempt at mathematics.

$\endgroup$

3 Answers 3

2
$\begingroup$

I do not know why you selected an exponential model but let us admit it for a time.

You want to model your data according to $$y=a \text { } e^{k t}$$ This model is intrinsically nonlinear with respect to its parameters and the problem with non linear square fit is a need of "reasonable" starting values for the parameters. As already said in other comments and answers, you can first transform the problem to a linear form taking the logarithms of both sides; this leads to $$\log(y)=c+kt$$ So, a first linear regression leads to $$\log(y)=2.21553+0.00749922 t$$ So the parameter estimates for the nonlinear model are $a=e^c=9.16627$ and $k=0.00749922$. Starting from here the nonlinear fit, the obtained model is $$y=9.25301 e^{0.00715341 t}$$ You should notice that the parameters changed when going from the linearized model to the nonlinear model (and this is normal).

However, if you plot on the same graph the curve and the data points, you should notice that the fit is not good. You could have noticed this before any calculation using a scatter plot of your data $\log(y)$ vs $t$.

As suggested by Biswajit Banerjee, a sigmoidal model $$y = \frac{a}{b + \exp(kt)}$$ should probably be much better (a scatter plot of $y$ vs $t$ reveals such a trend). Just as Biswajit Banerjee did and wrote, the best model is $$y=\frac{22.8793}{1.77611 +e^{-0.058405 t}}$$ which almost perfectly reproduces all your data (see the second graph Biswajit Banerjee provided in his answer). For $t=20$, this model predicts a value of $10.9624$.

For the first model, the coefficient of determination is $R^2=0.999306$ (corresponding to a sum of squares equal to $0.77803$) while for the second model $R^2=0.999993$ (corresponding to a sum of squares equal to $0.00765$) which is incredibly better.

$\endgroup$
3
  • $\begingroup$ Thanks for all the help. It's a locomotion type problem I'm trying to solve. I'm trying to calculate the movement of the driven link arm that is push/pulled along a slot by a drive wheel. Specifically the up and down distance vs. the angle of the wheel. I guess really it's a sinusoidal motion, as the figures reverse after 45 degrees. Would that make any difference to the model? $\endgroup$
    – Mattarn
    Mar 28, 2014 at 22:00
  • $\begingroup$ If you think that it's a sinusoidal motion, why did you consider an exponential model ? Could you post the data for a full range of what you call $degrees$ ? $\endgroup$ Mar 29, 2014 at 4:52
  • $\begingroup$ Mostly because the drive wheel never completes a full rotation. So I saw the data as an exponential growth and decay. Here's the full table (which in hindsight I should of posted originally): 5 | 9.0949720917 10 | 9.788059925 15 | 10.4054090336 20 | 10.9435666945 25 | 11.3984372031 30 | 11.7665587215 35 | 12.045129627 40 | 12.2320298195 45 | 12.325836884 50 | 12.2320298195 55 | 12.045129627 60 | 11.7665587215 65 | 11.3984372031 70 | 10.9435666945 75 | 10.4054090336 80 | 9.788059925 85 | 9.0949720917 $\endgroup$
    – Mattarn
    Apr 1, 2014 at 2:45
1
$\begingroup$

I'm not sure what you want to know, but here's a guess.

enter image description here

The dots in the image are your data and the solid line is a curve fit to the data using the function $$ \theta = a\log(kt) $$ where $\theta$ is the angle and $t$ is the percentage. The fit parameters are $a$ = 1.58 and $k$ = 55.3. Once you have a fit you can find values within the range of interest (excluding $t = 0$).

Another option is to fit a sigmoidal curve as shown in the figure below. enter image description here

The equation in this case is $$ \theta = \frac{a}{b + \exp(-kt)} $$ with fitted parameters $a$=22.9, $b$=1.78, $k$=0.06.

Alternatively you can interpolate using linear (or higher order/NURB/spline) interpolation between points.

$\endgroup$
1
$\begingroup$

You're pretty close!! The way you seem to be doing it is to make your approximation go through the two endpoints. Say we let $$y(t)=a\,e^{k(t-5)}$$ Then $$y(5)=a\,e^{k\cdot 0}=a\cdot1=a$$

Let me write $c_d$ for the data point at $d$ degrees (so I don't have to write out those long decimals, if you don't mind). $y(5)$ should be $c_5$ (9.094...) so we let $$a=c_5,\hspace{3mm}y(t)=c_5\,e^{k(t-5)}$$ Now we also want $$y(45)=c_5\,e^{40k}=c_{45}$$ and I get for k $$k=\frac{1}{40}\ln\left(\frac{c_{45}}{c_5}\right)$$

That's one way to get a formula. A better way, which incorporates all the data points, is to use the so-called "least-squares regression." Let's write again (not using the t-5 trick this time) $$y(t)=ae^{kt}$$ Then $$\ln\big(y(t)\big)=\ln(a)+kt$$ Let $$Y(t)=\ln\big(y(t)\big),\hspace{3mm}C=\ln(a)$$ We want to find a linear function $$Y=C+kt$$ that goes through the points $\bigg(\text{degrees},\ln\big(\text{Percent}\big)\bigg)$. Our new table is $$\begin{array}{|c|c|} \hline \text{Degrees} & \text{Percent} \\ \hline 5 & \ln9.0949720917 \\ 10 & \ln9.788059925 \\ 15 & \ln10.4054090336 \\ 20 & \ln10.9435666945 \\ 25 & \ln11.3984372031 \\ 30 & \ln11.7665587215 \\ 35 & \ln12.045129627 \\ 40 & \ln12.2320298195 \\ 45 & \ln12.325836884 \\ \hline \end{array}$$

You can use a complicated formula or a calculator to find the regression equation... I got (careful here, I used Excel and I'm not very familiar with it so this may be wrong) $$Y=2.215532381+0.007499221\,t$$ so $$y(t)=e^{2.215532381+0.007499221\,t}$$ and that is your equation.

$\endgroup$

You must log in to answer this question.

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