tylerl-uxai tylerl-uxai - 2 years ago 103
Javascript Question

What does the e equate to in the sigmoid function?

How do I know what the letter e equals in the sigmoid function?


In javascript is it just

return 1/(1+Math.E^(x));
Or is E not euleger's number?

console.log(1/(1+Math.exp(0))); // .5
console.log(1/(1+2.718281828459045^(0))); // 0.3333333333333333

Math.exp definitely works but when I do Math.exp(1) I get 2.718281828459045. When I plug that in and raise it to a power, it breaks?

Solution by @blgt

console.log(1/(1+Math.pow(2.718281828459045, 1))); // 0.2689414213699951 It works!

Answer Source

e is eulers number. In javascript, use Math.exp(x) to obtain it:


To get 1/(1+e^x) in javascript, use

var y = 1 / (1 + Math.exp(x));  // y = 1/(1+e^x)

The ^ symbol is the XOR operator, not to be confused with the mathematical exponent operator. To get the exponent n of a base number b, use


If you insist on "extracting" the value of e before using it, use this:

var e = Math.exp(1);
var y = Math.pow(e,x); // = e^x
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download