Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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

share|improve this question
    
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? –  user53153 Feb 6 '13 at 20:05
    
Ok just for [0, 1]; it really doesn't matter what happens outside that interval. –  Hugo S Ferreira Feb 7 '13 at 17:11
add comment

2 Answers

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

share|improve this answer
    
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 Apr 8 '13 at 4:32
1  
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. –  Rahul Apr 8 '13 at 5:39
    
Thank you. Seems like I can also use $$g(x) = p^{-1/x}, p \ge 2$$ to control the shape. –  Anton Apr 8 '13 at 8:36
add comment

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.

share|improve this answer
    
Also, a somewhat related question was answered recently. –  user53153 Feb 9 '13 at 2:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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