8

I'm looking for the analytic expression of a computationally cheap sigmoid that passes through the points (0, 1) and (1, 0). Thoughts?

  • Is it okay if it's only defined on the interval $[0,1]$? If you want it to also be defined on all real axis, should it stay $0$ for inputs $x>1$ and $1$ for negative inputs? –  Feb 06 '13 at 20:05
  • Ok just for [0, 1]; it really doesn't matter what happens outside that interval. – Hugo Sereno Ferreira Feb 07 '13 at 17:11

2 Answers2

9

An extremely cheap option is the cubic spline with zero derivatives at both endpoints: $$f(x)=1-3x^2+2x^3.$$ enter image description here

  • Rahul Narain, if I want to have even smoother curve at the endpoints, then I must use a higher order spline (5th, 7th etc), right? Is there another option, where I can have controllable smoothness (via parameter), which doesn't increase computational complexity with the increase of smoothness? (The second answer doesn't work for me, as I must strictly satisfy end point conditions). – Anton Roslov Apr 08 '13 at 04:32
  • 2
    You can try just using $f(x)=\dfrac{g(1-x)}{g(x)+g(1-x)}$ where $g(x)=\exp(-1/x)$, whose derivatives of all orders are zero at the endpoints. –  Apr 08 '13 at 05:39
  • 1
    Thank you. Seems like I can also use $$g(x) = p^{-1/x}, p \ge 2$$ to control the shape. – Anton Roslov Apr 08 '13 at 08:36
3

The logistic function is computationally cheap, and with a linear transform it can be adapted to $[0,1]$ interval: $\displaystyle \varsigma (x) = \frac{1}{1+\exp(6\cdot(2x-1))}$ is shown here. logistic

Strictly speaking, the curve misses both target points by $1/(1+e^6)\approx 0.002$. If this is a problem, tweak it: $$\varsigma (x) = \frac{a}{1+\exp(6\cdot(2x-1))}-b \ \text{ where } a= \frac{1+\exp(-6)}{1-\exp(-6)}, \ b = \frac{1}{\exp(6)-1}$$ satisfies $\varsigma(0)=1$ and $\varsigma(1)=0$. Here $a\approx 1.005$ and $b\approx 0.0025$ are computed only once.

Of course, $6$ can be replaced by another number throughout the formulas.