21st Century Sigmoid Func

I was playing with my sigmoid function, and Wolfram Alpha, seeing how the formula integrated and differentiated and so on. One thing that’s a bit awkward with it is how the k value is such that you need a large value for a straight line, and a small value for a sharp curve.

So I tried to replace k with 1/k to see what happened. I had never tried to simplify the equation from here, never occurred to me to try. Well it turns out that the extra divisions simplify and yields a potentially superior function.

It behaves fine for k=0, and the larger the value of k, the sharper the curve.

Here is the original function:


Changing k to 1/k gives:


And this simplifies to:


The new formula works for values of k great than 0. One disadvantage over the previous formula is that to work cleanly a variant needs to be used to create curves that other way (if you recall, the original version is invalid for k values between 0 and -1). However accepting this and using different formulae for positive and negative values of k will also allow us to remove the invalid zone between 0-1. Here is the version that works for negative k, valid from 0 to minus infinity:


So we have two cases and two formulae, but as a challenge I wanted to write it as a single formula so I could get Wolfram Alpha to plot it. One way is to use the sign function, that returns -1, 0 or 1 depending on the sign of a number. A bit of playing around gave me:

OK, it seems to be getting complicated, but in code you would use two separate formulae with an if statement. But here I am trying, for fun, to get Wolfram Alpha to plot the thing. The formula itself gives a lot of information. It is also interesting because in this form we have taken a discontinuous function and made it continuous by cutting out a piece.  Anyway, never mind that, here’s the final result:

2 Responses to “21st Century Sigmoid Func”

  1. Ben Says:

    Hi Dino, can you post the Wolfram Alpha text formula that you used to generate the 21st Century plot above? I came up with this:

    plot ((k(1/2*(-sgn(k)+1))-1) t)/(k t-1-k*(1/2*(sgn(k)+1))) k = -10 to 10 t = 0 to 1

    And it looks equivalent to your formula, but there is a small discontinuity along k=0 which does not show up in your plot. I’m not sure what the ‘x’ character that appears in your formula means. I assume that it’s multiplication, but other instances of multiplication in your formula are implicit.

    • Dino Dini Says:

      It looks like the formula is correct, I also see the glitch you mention, but I think that is a bug in Wolfram Alpha. The x you mention was inserted by Wolfram Alpha, I guess because it could not fit the expression in one line (so it is times t and explicit because the t is underneath). Wolfram Alpha does not seem to format it like that now.

      You may want to try it in another package such as Maxima.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: