Finding the two unknown constants of the logistic function $f(x) = \frac{158}{1+e^{s(x-c)}}+22$

198 Views Asked by At

I'm trying to find the two unknown constants of the following function:

$$f(x) = \frac{158}{1+e^{s(x-c)}}+22$$ Where s and c are constants, and 22 (or $y_{min}$) and 180 (or $y_{max}$) are the horizontal asymptotes. c is the integration constant.

This was integrated from the following ODE (Ricatti equation):

$$\frac{s}{158}\frac{dy}{dx}=a(y-22)(180-y) , f(0) = y_0 > 22 $$

I can assume that f(0) lies near the horizontal asymptote. Additionally, I have the following equations:

$$f(0) = y_0 = \frac{158}{1+e^{sc}}+22$$ Hence $$c = \frac{1}{s} log \frac{180 - y_0 }{y_0 - 22}$$

How do I find both constants mathematically? I realize that I need two equations, but am unsure of how I can find them. From plugging in this into Desmos, I have found that c is the inflection point of the graph, while s is responsible for the shape of the curve: https://www.desmos.com/calculator/hwg4vsewro

The broader context of this question is that I'm finding a logistic function to fit a set of data (x is time, y is angle).

For context of the equations, I followed this source: http://sciendo.com/article/10.2478/fman-2020-0007

This is my raw data. Left column is x value(seconds); right is y value(angle).

x y

0 22

60 23

120 24

180 27

240 32

300 32

360 36

420 36

480 39

540 41

600 42

660 45

720 46

750 51

780 54

810 57

840 63

870 79

900 103

930 124

960 155

990 177

1020 180

1080 180

1140 180

1200 180

I did not find an explanation of exactly how they find s and c, although the source has some quite complex equations involving higher order derivatives.

(One that I think might be useful involves the x-value $x_0$, where the function's second derivative takes its maximum value.

$$f(x_0) = \frac{y_{max}-y_{min}}{1+e^{s(x_0-c)}}+y_{min}$$ $$f(x_0) = y_{min} + 0.211(y_{max}-y_{min}) = 22 + 0.211(180-22) =55.338$$ No explanation why $\frac{1}{1+e^{s(x_0-c)}}=22$. From which it is somehow calculated: $$x_0 = c - \frac{1.319}{s}$$)

1

There are 1 best solutions below

11
On

$$f(x) = \frac{158}{1+e^{s(x-c)}}+22$$ The given data is : $$(x_1,f_1),(x_2,f_2),..., (x_k,f_k),..., (x_n,f_n)$$ Let : $$Y(x)=\ln\left(\frac{158}{f(x)-22}-1 \right)$$ So, for each $f_k$ compute : $$Y_k=\ln\left(\frac{158}{f_k-22}-1 \right)$$ The original equation becomes : $$Y=s\:x-s\:c$$ You can compute approximate values of $(s)$ and $(-s\:c)$ thanks to linear regression (Least Mean Squares).

NOTE: Some difficulties may arrise due to eventually negative argument of the logarithm. That is why a representative example of data would be useful to check if the difficulties appear in your case and eventually suggest what to do.

NOTE: If a particular criteria of fitting is specified, you need a non-linear regression method. Then use a specialized software involving itterative calculus and guessed initial values of the parameters. The approximate values found above can be used as initial values.

UPDATED ANSWER with the given data.

Drawing $Y(x)=\ln\left(\frac{158}{y(x)-22}-1 \right)$ shows this shape of curve :

enter image description here

The curve is far to be linear. This proves that the chosen model $(1)$ is not convenient to obtain a good fitting whatever the method of calculus of the parameters.

$$y=a+\frac{b}{1+e^{s(x-c)}} \tag {model 1}$$

As a consequence the above proposed method is of no interest in the present case.

We have to look for another model.

For example one can try with the sum of two logistic functions :

$$y=A+\frac{b_1}{1+e^{s_1(x-c_1)}}+\frac{b_2}{1+e^{s_2(x-c_2)}} \tag {model 2}$$

The result is much better. Below, the comparison between the two models.

enter image description here