Analytic calculation of confidence intervals