How can I calculate confidence intervals of a probability obtained by my logistic regression model? I have fit my own logistic model and I am using it to calculate the probabilities of different outcomes. I would like to know how I can obtain the confidence intervals of these probabilities.
I am using scikit in python, but I am happy to know just the mathematical answer.
 A: The typical logistic regression model is written as something like
$$\log\left(\frac{\pi}{1-\pi}\right)=x^T\beta$$
where we model the log-odds by a linear combination of our predictor variables $x$.  In the equation above $\pi$ would be the probability that you are interested in calculating a confidence interval for.  
Now, rearranging terms, we know that we can estimate the probability $\pi$ as 
$$\hat\pi=\frac{e^{x^T\hat\beta}}{1+x^T\hat\beta}$$
where $\hat\beta$ are the estimated coefficents from your linear regression.
It should be noted that, since maximum likelihood estimates
are invariant to transformation, $\hat\pi$ may also be considered the
maximum likelihood estimate of $\pi$.
So now, construction of confidence interval proceeds using the fact that
$$\frac{x^T\hat\beta-x^T\beta}{\hat{SE}}\stackrel{.}{\sim} z$$
where $$\hat{SE}=\sqrt{x^T(X^TWX)^{-1}x}$$
We can then construct a $(1-\alpha)$ confidence interval for $x^T\beta$ as
$$(L,U)=\left(x^T\hat\beta-z_{\alpha/2}\hat{SE},\,x^T\hat\beta+z_{\alpha/2}\hat{SE}\right)$$
and thus, finally, a $(1-\alpha)$ confidence interval for $\pi$ is therefore
$$\left(\frac{e^L}{1+e^L},\,\frac{e^U}{1+e^U}\right)$$

Some of the details above I have excluded assuming that you understand how a logistic regression works in general, and its corresponding design matrix, etc.
