---
title: 'HW 3: Number 3'
#author: "Mark"
#date: "9/10/2017"
header-includes:
   - \usepackage{color, colortbl}
   - \definecolor{LightGray}{gray}{0.9}
   - \definecolor{Gray}{gray}{0.75}
output: pdf_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

Judging from the grades, problem number 3 on homework 3 seems to have been a fairly tough problem - particularly, parts (d) and (e) which require you to find quantiles. Here's my approach to part (d).

## Statement

Here's the statement as it appears to me (everyone's is a little different):

The cholesterol levels of an adult can be described by a normal model with a mean of 195 mg/dL and a standard deviation of 26 mg/dL.

 d) Estimate the interquartile range of cholesterol levels.

### Solution 1 (using R)

As we learned in our lab the other day, the `qnorm` command can be used to compute quantiles. For example, `qnorm(0)` should return 0.5, since $50\%$ of the area under the standard normal curve is to the left of zero and $50\%$ is to the right of zero. If we'd like to compute the interquartile range for the standard normal distribution, we could do:

```{r}
qnorm(0.75)-qnorm(0.25)
```

To find the IQR for the given distribution, we could simply specify the mean and standard deviation that we need for the problem:

```{r}
qnorm(0.75, 195, 26)-qnorm(0.25, 195, 26)
```

It's worth pointing out that there are other formulae that work for these computations and that they're generally pretty easy to find, if you understand the symmetry of the normal distribution. For example, since the standard normal is symmetric about the origin, should find that

```{r, eval=F}
qnorm(0.75) == -qnorm(0.25)
```

So that another way to do that first computation is as `2*qnorm(0.75)`.  This symmetry is illustrated in the following picture:

```{r, echo=F}
plot(dnorm, -3,3, xaxt='n')
lines(c(qnorm(0.2),qnorm(0.2)), c(-0.1,dnorm(qnorm(0.2))), lty=3)
lines(c(qnorm(0.8),qnorm(0.8)), c(-0.1,dnorm(qnorm(0.8))), lty=3)
axis(1, at=qnorm(c(0.2,0.8)), labels = c('qnorm(0.25)=-0.67','qnorm(0.75)=0.67'),cex.axis=.8)
```

### Solution 2 (using tables)

An alternative approach starts from the fact that the IQR for the standard normal distribution is $1.35$. Thus, the IQR for an alternative normal distribution with a standard deviation of $s$ is simply $1.35s$. For my problem, where the standard deviation was $26$, the IQR should be 
$$1.35 \times 26 = 35.1,$$
in agreement with the R computation.

Of course, for this to work, you've got to know that the IQR of the standard normal is $1.35$ and, in fact, it's a good idea to know the standard normal well because it translates so easily to other normal distributions. If you don't know this fact, though, you can look it in a standard table; the relevant values are shown in the table below.


\begin{table}[!htbp]
\setlength{\belowcaptionskip}{15pt plus 3pt minus 2pt}
\caption{A few relevant $Z$ values}\begin{center}{\small
\begin{tabular}{c | c | rr>{\columncolor{LightGray}}r>{\columncolor{LightGray}}rr |}
$Z$ & $\cdots$ & 0.05 & 0.06 & 0.07 & 0.08 & 0.09 \\
  \hline
  \hline
  $\cdots$ &$\cdots$ &$\cdots$ &$\cdots$ &$\cdots$ &$\cdots$ &$\cdots$ \\
  0.4 & \vdots\ \vdots & \scriptsize{0.6736} & \scriptsize{0.6772} & \scriptsize{0.6808} & \scriptsize{0.6844} & \scriptsize{0.6879} \\
  \hline
  0.5 & \vdots\ \vdots & \scriptsize{0.7088} & \scriptsize{0.7123} & \scriptsize{0.7157} & \scriptsize{0.7190} & \scriptsize{0.7224} \\
  \rowcolor{LightGray}
  0.6 & \vdots\ \vdots & \scriptsize{0.7422} & \scriptsize{0.7454} & \cellcolor{Gray}\scriptsize{0.7486} & \cellcolor{Gray}\scriptsize{0.7517} & \scriptsize{0.7549} \\
  0.7 & \vdots\ \vdots & \scriptsize{0.7734} & \scriptsize{0.7764} & \scriptsize{0.7794} & \scriptsize{0.7823} & \scriptsize{0.7852} \\
  $\cdots$ &$\cdots$ &$\cdots$ &$\cdots$ &$\cdots$ &$\cdots$ &$\cdots$ \\
  \hline
   \hline
\end{tabular}}
\end{center}
\end{table}
