0

I have some data that I would like to go as input on a function as $x$, its values range from 1 to ~5000. I would like to have $f(x)$ output values which follow a sigmoid like distribution.

I was able to find some equations that do that. The problem is that they don't include -1 and 1 values in $f(x)$'s range. Without saying I would need its values to be in range of $[0,1]$ instead of $]-1,1[$.

How can I maybe change one of those equations in a way that $f(x)$ follows these restrictions? As this image shows I was able to put $erf(x)$'s between ]0,1[ but not [0,1].

md2perpe
  • 30,042
gudé
  • 31
  • 4
  • What exactly are you looking for? You can do a silly thing like $f(x) = \max(0, \min((x+1)/2, 1))$ which is flat at $0$ on $(-\infty, -1)$, then increases linearly to $1$ on $(-1, 1)$, and then stays flat at $1$ on $(1, \infty)$. This has range $[-1, 1]$, but you will probably complain that this is not sigmoid-like enough. – angryavian Oct 03 '19 at 21:50
  • What is $]0,1[$ supposed to mean? – Ryan Oct 03 '19 at 21:51
  • @angryavian I feel like he’s looking for something like the logistic curve https://en.m.wikipedia.org/wiki/Logistic_function – Ryan Oct 03 '19 at 21:53
  • 2
    @RyanGreyling Some people use $]0, 1[$ to denote the open interval $(0, 1)$. – angryavian Oct 03 '19 at 21:54

3 Answers3

1

Here is an example of a smooth function that is $0$ for $x \le 0$ and $1$ for $x \ge 1$. It is defined as $\frac{f(x)}{f(x) + f(1-x)}$ where $f(x) = \begin{cases} e^{-1/x} & x > 0 \\ 0 & x \le 0 \end{cases}$.

angryavian
  • 93,534
  • I wasn't able to reproduce your example. My values are never negative, neither 0. So I suppose the equation would be always like: $\frac{e^{-1/x})}{(e^{-1/x} + e^{-1/(1-x)}}$, right? If put like this, it gives an indeterminate answer for $x=0$ and $x=1$. – gudé Oct 04 '19 at 16:32
  • @gudé When $x=0$ then $f(x) =f(0) = 0$ and $f(1-x) = f(1) = e^{-1}$ and we obtain $\frac{0}{0+1}=0$. When $x=1$ then $f(x) = f(1) = e^{-1}$ and $f(1-x)=f(0) = 0$ so we obtain $\frac{e^{-1}}{e^{-1} + 0} = 1$. – angryavian Oct 04 '19 at 21:07
0

Try using $\sigma (x)= \frac{1}{1+e^{-x+2500}}$ for $0 <x<5000$ with $\sigma (0) =0$ and $\sigma (5000) = 1$ otherwise.

The values of the logistic curve are extremely close to $0$ and $1$ at $x=0$ and $x=5000$ so it wouldn’t make a difference anyway. It’s close enough that an average calculator wouldn’t be able to notice the difference.

Ryan
  • 1,666
  • Considering only the restrictions I pointed out in the question, your solution is ok. Although I want the function's smoothness to be kept. In your solution this doesn't happen, unfortunately. – gudé Oct 03 '19 at 22:21
  • You might find what you’re looking for here https://math.stackexchange.com/questions/1832177/sigmoid-function-with-fixed-bounds-and-variable-steepness-partially-solved – Ryan Oct 03 '19 at 22:30
0

If you have any function $f: [0,5000] \to \mathbb{R}$ that you like, i.e. sigmoid-like, smooth, monotonic, etc, and the only problem you have is that $f(0) > a$ slightly and $f(5000) < b$ slightly, when you would like exactly $f(0)=a, f(5000)=b$, then how about just rescaling the thing vertically?

$$a + {b - a \over f(5000) - f(0)} (f(x) - f(0))$$

Many of the curves you found do not reach their asymptotic values. If you want to artificially reach the asymptotic values, and you know exactly where you want to reach them (at $0$ and at $5000$) then rescaling is the easiest.

The OP mentioned "~5000" though, so I am not sure you want to reach the higher asymptotic value at exactly $5000$...

antkam
  • 15,638
  • My values actually go from 1 to about 5000, I was wrong. I am actually reducing the size of a graph by removing nodes. The 5000 concerns the depth of the nodes in these graphs. Some graphs have more other fewer depths. In other words, I need $f(x)$ values in which follow a sigmoidal distribution based on $x$ values which are the depth of nodes in a graph. I will check how your option works! Thanks for the reply. – gudé Oct 04 '19 at 16:29
  • If input $x > 5000$ is possible, and you want $f$ to be monotonically increasing, and you want to reach $f(y) = b$ at some $y$, then you gotta decide what is the minimum $y$ for which $f(y) = b$ becomes true (and then $f(z) = b ,, \forall z > y$). That's a design choice for you to make. Whether that $y$ is $5000$ or not is up to you. – antkam Oct 04 '19 at 17:19