Transform Logistic/Sigmoid function

3.2k Views Asked by At

Please excuse any incorrect terminology. I want to adjust the curve of a logistic function to make it more or less steep while still reaching the asymptote points at the same value of x.

Here is a standard logistic function $f(x) = \frac{L-a}{1+e^{-k(x-x_0)}}+a$ where L=1, a=0, k=1, $x_0=0$: standard logistic function

I know that I can change the steepness by changing k. For example, if k=0.5 I get the line shown in red: logistic function with k=0.5

I can change the minimum and maximum values of f(x) by changing a and L, respectively. I can change the x value where f(x) hits the midpoint between a and L by changing $x_0$.

My goal is to have a function such as this:
$$ g(x) = \begin{cases} 0 & \quad \text {if } x<-5 \\ f(x) & \quad \text {if } -5\geq x\leq 5\\ 1 & \quad \text {if } x>5 \end{cases} \ $$

Where f(x) looks like the line shown here in yellow as given by $f(x)= \frac{1.1-(-0.9)}{1+e^{-0.05(x-0)}}+-0.9$: goal function in yellow

This yellow line has the 'steepness' of the function where k=0.5 (red line) but has approximately the same minimum and maximum (x, f(x)) points as the standard logistic function (blue line). I arrived at the current yellow line by manually adjusting a and L values until the line looked correct.

My questions are:

  1. Is there some other transformation I can use on the logistic function to make it look like the yellow line (without manually guessing values for L and a)?

  2. Is there a different/better formula than the logistic function I can use to get a curve that looks like this yellow line?

1

There are 1 best solutions below

0
On

I think I understand now what you're trying to do, and I may have a workable solution for you. First let's state the goal:

We want to find a piecewise function $g(x)$ on $(-\infty, \infty)$ such that for some $\varepsilon > 0$ we have $g(x)=y_m$ for all $x < x_0-\varepsilon$ and $g(x)=y_M$ for all $x > x_0+\varepsilon$, and such that $g(x)$ is sigmoid for $x$ between $x_0-\varepsilon$ and $x_0+\varepsilon$. Additionally, you would like to be able to control the slope of the sigmoid part.

If we let $f$ be the logistic curve you chose: $$ f = a + \frac{L-a}{1 + e^{-k(x-x_0)}} $$ then $$ f'= k(a-L) \frac{e^{k(x+x_0)}}{\left( e^{kx} + e^{k x_0} \right)^2}$$ The curve achieves its maximum slope at $x=x_0$, given by $$ f'(x_0)= \frac{1}{4}k(L-a) $$

Your first step is to choose the "steepness" $m=f'(x_0)$. Using the above, we get the constraint: $$ k=\frac{4m}{L-a} \qquad (1) $$ Now we need another equation relating $k$ and $L-a$ so that we can solve for their values. This is provided by the requirement that $f(x_0+\varepsilon)=y_M$, i.e.: $$ y_M=a+\frac{L-a}{1+e^{-k\varepsilon}} $$ Using $(1)$ in the above gives: $$ y_M = a + \frac{L-a}{1 + e^{-\frac{4m\varepsilon}{L-a}}} $$ Using symmetry, we can write $a=y_m + y_M - L$ and therefore $L-a=2L-(y_m+y_M)$. Plugging this in to the above, we can solve for $L$ in: $$ y_M = y_m+y_M-L + \frac{2L-(y_m+y_M)}{1 + e^\frac{-4m\varepsilon}{2L-(y_m+y_M)}}$$ At this point, things get really ugly. You can solve numerically using the method of your choice, though. Once you have $L$, you can find $a$ using the relation $a=y_m+y_M-L$ from before. Now that you have values for $k$, $a$, and $L$, you are done! Define:

$$ g(x) = \left\{\begin{matrix} y_m, & x < x_0 - \varepsilon \\ \frac{L-a}{1 + e^{-k(x-x_0)}}, & x_0-\varepsilon \leq x < x_0+ \varepsilon \\ y_M, & x \geq x_0 + \varepsilon\end{matrix} \right. $$

Here is an example of using this method with $m=2$, $\varepsilon=4$, $x_0=1$, $y_m=-2$, and $y_M=3$:

Sigmoid