I learned about the very interesting Sigmoid function today in my Math Class. When you pass it a number, usually a difference of two other variables, you’ll get a value between 0 and 1.

I wanted to see what would happen when I tried it on a range of numbers, so I wrote it up quickly in Java.

class Calc { public static double sigmoid(double x) { return (1/( 1 + Math.pow(Math.E,(-1*x)))); } }

For example, let’s say you have 18 and 8. You subtract 8 from 18 and get ten and pass it to the Sigmoid function. You’re returned with 0.9999546021312976. If you had a difference of 0 though, you would get .50 and if you had a negative difference, like -18, get a really tiny number that’s bigger than 0. So in short, the Sigmoid function is easy and quite interesting.

Is there meant to be another closing bracket at the end of line 3?

You’re absolutely right! That’s what I get for putting it into one line.

[…] is the original source, Thanks to the […]

how about:

return (1 / (1 + Math.exp(-x)));

That looks like it’ll work too.