Quantiles of the Normal

Contents

Quantiles of the Normal

Now take a Normal:

\[ X \sim N(\mu, \sigma^2), \]

and let \(F(x) = p(X \le x)\) be its CDF. The \(q\)-quantile of \(X\) is defined through the solution of the non-linear equation:

\[ F(x_q) = q. \]

Recall that we have managed to express the Normal CDF \(F(x)\) in terms of the standard Normal CDF \(\Phi(z)\):

\[ F(x) = \Phi\left(\frac{x-\mu}{\sigma}\right). \]

We can use this to express \(x_q\) in terms of \(z_q\), i.e., the \(q\)-quantile of the standard Normal. We have by substitution in the defining equation of \(x_q\):

\[ \Phi\left(\frac{x_q-\mu}{\sigma}\right) = q. \]

By comparing to the defining equation of \(z_q\),

\[ \Phi(z_q) = q, \]

we get that:

\[ z_q = \frac{x_q - \mu}{\sigma}, \]

or, in terms of \(x_q\):

\[ x_q = \mu + \sigma z_q. \]

Alright, so if we know the \(q\)-quantiles of the standard Normal we can get the \(q\)-quantiles of a Normal. The median is trival:

\[ x_{0.5} = \mu, \]

since \(z_{0.5}\).

The \(0.025\)-quantile is:

\[ x_{0.025} \approx \mu - 1.96\sigma \approx \mu - 2\sigma. \]

And the \(0.975\)-quantile is:

\[ x_{0.975} \approx \mu + 1.96\sigma \approx \mu + 2 \sigma. \]

So, we can say (95% central credible interval):

\(X\) is between \(\mu - 2\sigma\) and \(\mu + 2\sigma\) with 95% probability.

Similarly, we can find the \(0.001\)-quantile:

\[ x_{0.001} \approx \mu - 3.09 \sigma \approx = \mu - 3\sigma, \]

and the \(0.999\)-quantile:

\[ x_{0.999} \approx \mu + 3.09\sigma \approx = \mu + 3 \sigma, \]

which we can use to say (99.8% central credible interval):

\(X\) is between \(\mu - 3\sigma\) and \(\mu + 3 \sigma\) with 99.8% probability.

These are good things to remember, but even if you don’t, you can still use scipy.stats to find quantile and central credible intervals of any Normal:

import scipy.stats as st
mu = 5
sigma = 2
X = st.norm(loc=mu, scale=sigma)
x_025 = X.ppf(0.025)
x_975 = X.ppf(0.975)
print('X is between {0:1.2f} and {1:1.2f} with probability 95%'.format(x_025, x_975))
print('Compare to the interval found through the standard normal')
print('** X is between {0:1.2f} and {1:1.2f} with probability 95%'.format(mu - sigma * 1.96, 
                                                                          mu + sigma * 1.96))
X is between 1.08 and 8.92 with probability 95%
Compare to the interval found through the standard normal
** X is between 1.08 and 8.92 with probability 95%

Questions

  • Modify the code above to find the 99.8% quantile of \(X\).