0
$\begingroup$

I have an equation which is meant to model a non-linear burn down chart:

$$ f(x) = \frac{k-k^x}{k-1}$$

where

$$k = e^\frac{1}{c}$$ enter image description here

If I have an error function like this:

$$ \text{error} = \sum_{i=1}^N \sqrt{(f(x_i) - y_i)^2} $$

where $y$ is the empirical data gathered from real burn downs.

I wish to find the optimal k to fit $f(x)$ to my data?

I thought I could get the derivative of the error function with respect to $k,$ set it to zero

$$ \frac{d(\text{error})}{dk} = 0 $$

$$\frac{2(k-k^x-y(k-1))(k^x-xk^x+xk^{x-1}-1)}{(k-1)^3} = 0, $$

and solve for $k.$

But the Symbolab software package says: "Steps are currently not supported for this problem" when I ask it to solve for $k$:

$$ \text{solve for } k,\:\frac{2(k-k^x-y(k-1))(k^x-xk^x+xk^{x-1}-1)}{(k-1)^3} = 0 $$

Am I going about this the right way?

$\endgroup$
  • 2
    $\begingroup$ Would anyone care to explain the downvote? $\endgroup$ – Frpzzd Mar 29 '18 at 23:18
  • $\begingroup$ Since I'm not the downvoter, I can only guess, but there are a couple of reasons why one might downvote: (1) it is not entirely clear what the question is (find the optimal $k$? or get something called "Symbolab" to find the optimal $k$?); (2) it looks like this might be a question about how to use a certain software package (therefore off-topic); (3) this might be a better question for the folk on Cross Validated (the statistics SE site), as it looks like something that they might have more expertise in. $\endgroup$ – Xander Henderson Mar 29 '18 at 23:22
  • $\begingroup$ I wish to find the optimal value of k that minimizes the error function. I figured it was a Math problem since it's just calculus and algebra. This can be done by hand or using software. But, Symbolab is a software package which shows you 'how' it derived the answer when it does work. I didn't think it would be useful to mention this in the question, as I don't mind how people choose to solve the problem. $\endgroup$ – COOLBEANS Mar 29 '18 at 23:30
  • $\begingroup$ The derivatives of the defined error function are really wrong. But do not worry about it since you will not be able to solve it for $k$. Have a look to my answer : you can do all of it using Excel. Cheers. $\endgroup$ – Claude Leibovici Mar 30 '18 at 8:32
3
$\begingroup$

If you did not already study numerical methods, the best is to use trial and error.

Considering $n$ data points $(x_i,y_i)$ and $$\text{error}(k)=\sum _{i=1}^n \sqrt{\left(\frac{k-k^{x_i}}{k-1}-y_i\right)^2}=\sum _{i=1}^n\left|\frac{k-k^{x_i}}{k-1}-y_i\right|$$ $$\frac d {dk}\text{error}(k)=\frac 1 {k(k-1)^2}\sum _{i=1}^n\left|k^{x_i} ( k+x_i(1-k))-k \right|$$ make a guess of $k$ and compute the corresponding $\text{error}(k)$. Build a plot and look for the minimum.

To get an idea of the ordre of megnitude, search for a point close to $x=\frac 12$ and, from the plot, say that the corresponding $y$ is $a$. As an estimate $$k_{est}=\frac{a^2}{(a-1)^2}$$ This gives you a rough idea of the area to explore.

For illustration purposes, let us consider the following data $$\left( \begin{array}{cc} x & y \\ 0.1 & 1.0 \\ 0.2 & 0.9 \\ 0.3 & 0.9 \\ 0.4 & 0.8 \\ 0.5 & 0.7 \\ 0.6 & 0.6 \\ 0.7 & 0.5 \\ 0.8 & 0.4 \\ 0.9 & 0.2 \end{array} \right)$$ So $k_{est}=5.45$ and explore to get the following results $$\left( \begin{array}{cc} k & \text{error}(k) & \frac d {dk}\text{error}(k)\\ 5.0 & 0.236891 & 0.145450 \\ 5.1 & 0.224471 & 0.142169 \\ 5.2 & 0.212320 & 0.139020 \\ 5.3 & 0.200437 & 0.135995 \\ 5.4 & 0.193029 & 0.133087 \\ 5.5 & 0.187903 & 0.130289 \\ 5.6 & 0.184563 & 0.127595 \\ 5.7 & 0.181282 & 0.125001 \\ 5.8 & 0.178060 & 0.122499 \\ 5.9 & 0.174895 & 0.120087 \\ 6.0 & 0.171784 & 0.117759 \\ \color{red}{6.1} &\color{red}{ 0.170319} & 0.115511 \\ 6.2 & 0.170899 & 0.113339 \\ 6.3 & 0.171468 & 0.111240 \\ 6.4 & 0.173610 & 0.109210 \\ 6.5 & 0.176056 & 0.107245 \\ 6.6 & 0.178464 & 0.105343 \\ 6.7 & 0.180836 & 0.103501 \\ 6.8 & 0.185655 & 0.101716 \\ 6.9 & 0.190419 & 0.099986 \\ 7.0 & 0.195104 & 0.098308 \end{array} \right)$$ If required, refine the step around $k=6.1$ and repeat (you would probably get $k\approx 6.05$) . In any manner, for $k=6.1$, the computed $y$ would be $$\{0.961,0.915,0.859,0.792,0.712,0.616,0.501,0.363,0.198\}$$

But there is a problem : the function is not continuous because the error function you defined is the sum of the absolute value of the residuals. Then, in spite of everything, working with the derivative is absolutely of no hope. In any manner, notice that, in the explored range, this derivative never cancels.

Edit

The problem would have been totally different if you had defined instead $$\text{error}(k)=\sqrt{\sum _{i=1}^n \left(\frac{k-k^{x_i}}{k-1}-y_i\right)^2}$$ Minimizing it is the same as minimizing its square that is to say $$\text{SSQ}(k)=\sum _{i=1}^n \left(\frac{k-k^{x_i}}{k-1}-y_i\right)^2$$ $$\frac d {dk}\text{SSQ}(k)=\frac 2 {k(k-1)^2}\sum _{i=1}^n\left(k^{x_i} ( k+x_i(1-k))-k \right)\left(\frac{k-k^{x_i}}{k-1}-y_i\right)$$ In such a case, you face a continuous function that you do not need to minimize; just find the zero of its derivative using Newton method starting from the guess. This is much simpler.

For the worked example, the iterates would be

$$\left( \begin{array}{cc} k & k_n \\ 0 & 5.44444 \\ 1 & 6.25913 \\ 2 & 6.51712 \\ 3 & 6.53674 \\ 4 & 6.53685 \end{array} \right)$$

and, for $k= 6.53685$, the computed $y$ would be $$\{0.963,0.918,0.8638,0.798,0.719,0.624,0.509,0.370,0.202\}$$

Even working with a very poor estimate, this will work fine (at the price of very few extra iterations) $$\left( \begin{array}{cc} k & k_n \\ 0 & 2.00000 \\ 1 & 3.02562 \\ 2 & 4.25968 \\ 3 & 5.46805 \\ 4 & 6.27031 \\ 5 & 6.51865 \\ 6 & 6.53676 \\ 7 & 6.53685 \end{array} \right)$$

$\endgroup$
  • $\begingroup$ And where did you come up with with $k_{est}$ ? $\endgroup$ – COOLBEANS Mar 30 '18 at 12:45
  • $\begingroup$ Ah, ok. I got your $k_{est}$ by solving for k, in $ \frac{k-k^{0.5}}{k-1} - a = 0$. Then, later to simplify the calculation I dropped the constant terms and rearranged in terms of k. $\endgroup$ – COOLBEANS Mar 30 '18 at 13:31
1
$\begingroup$

I don't think you have an analytical solution to the equation. Also, note that you take the derivative of the sum. Therefore instead of $$\frac{2\left(k-k^x-y\left(k-1\right)\right)\left(k^x-xk^x+xk^{x-1}-1\right)}{\left(k-1\right)^3} = 0 $$ you have $$\sum_{i=1}^N\frac{2\left(k-k^{x_i}-y_i\left(k-1\right)\right)\left(k^{x_i}-x_ik^{x_i}+x_ik^{x_i-1}-1\right)}{\left(k-1\right)^3} = 0 $$

Now you have a complicated equation, containing multiple (non-integer) powers of $k$. The only likely solution is numeric.

$\endgroup$
  • $\begingroup$ I haven't studied numerical methods, yet. But I appreciate the direction. I was probably mistaken in thinking this would be a nice quadratic bowl shaped function just because the error function was (......)^2 $\endgroup$ – COOLBEANS Mar 29 '18 at 23:40
  • $\begingroup$ The derivatives are much more complex than that. What you wrote is correct for the least-square method but not for the error function defined in the post. $\endgroup$ – Claude Leibovici Mar 30 '18 at 8:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.