This is a logistic sigmoid function:

I know x. How can I calculate F(x
Here's how you would implement the logistic sigmoid in a numerically stable way (as described here):
def sigmoid(x):
"Numerically-stable sigmoid function."
if x >= 0:
z = exp(-x)
return 1 / (1 + z)
else:
z = exp(x)
return z / (1 + z)
Or perhaps this is more accurate:
import numpy as np
def sigmoid(x):
return math.exp(-np.logaddexp(0, -x))
Internally, it implements the same condition as above, but then uses log1p.
In general, the multinomial logistic sigmoid is:
def nat_to_exp(q):
max_q = max(0.0, np.max(q))
rebased_q = q - max_q
return np.exp(rebased_q - np.logaddexp(-max_q, np.logaddexp.reduce(rebased_q)))
(However, logaddexp.reduce could be more accurate.)