Skip to main content

Normal distribution

The normal distribution is a ubiquitously useful distribution that turns up all over the place in statistics. You're probably already familiar but let's make sure you are:

Challenge

Pick a mean value μ\mu (start somewhere between −10-10 and 1010) and a variance vv (which must be positive - for example, 22 is a good starting choice). Then plot the density of the normal distribution over the continuous range x=−20⋯20x=-20 \cdots 20.

Note. the normal distribution density is given by dnorm() in R, but you have to specify the standard deviation (i.e. the square root of the variance) instead of the variance:

dnorm( x, mean = mu, sd = sqrt(v) )

How does the distribution differ as you vary μ\mu and vv?

for experts

The normal distributino density formula is:

x∣μ,v∼12∗π∗v⋅e12(x−μ)2vx|\mu,v \sim \frac{1}{\sqrt{2*\pi*v}}\cdot e^{\frac{1}{2}\frac{(x-\mu)^2}{v}}

Can you implement that directly, without dnorm()?

Cumulative desnity​

Just like binom, the normal distribution has a cumulative version called pnorm(). Plot that now.

The cumulative function is the result of adding up (integrating) the values in the normal distribution density from left to right.

Question

The graph of pnorm() goes up to 11 on the right - why?

Quantile function​

The quantiles tell you where in the range of xx the mass of the distribution is located. It is computed by qnorm().

For example, let's find the range on the left of a standard normal where at least 10% of the mass is:

qnorm(
p = 0.1,
mean = 10,
sd = 1
)

and the range on the right:

qnorm(
p = 0.1,
mean = 10,
sd = 1,
lower.tail = FALSE
)

Question. Where is 95% of the mass?