# Notes on Utility Statistical Operations

load("~/Dropbox/RProjects/Math 146 Notes/cdc.Rdata")

## Quantiles

How do we find a percentile value in a set of numbers?

The set of numbers must be in vector. Then we can apply the quantile function.

Example: Find the 73rd percentile of the normal distribution with mean 100 and standard deviation 15.

First get a sample of numbers from the distribution. Then apply the quantile function.

x = rnorm(100000,mean = 100, sd = 15)
pct73 = quantile(x,.73)
pct73
##      73%
## 109.4087

How about the opposite direction? We have a number from the distribution and we want to know its percentile ranking.

We can use the principle that the mean value of a logical expression is the fraction of cases for which the logical expression is true.

mean(x < 110)
##  0.74417

## Exercise

Use the cdc dataset. Find the 60th percentile of the height values.

quantile(cdc$height,.6) ## 60% ## 68 ## Exercise What is the percentile rank of 70 inches in the distribution of heights in cdc? ## Solution mean(cdc$height < 70)
##  0.6878

## The Theoretical Normal Distribution.

We dealt with this above by drawing a random sample, which can give us approximate answers, depending on the size of the sample. However, there are utility functions, which replicate the functionality of the normal curve table.

Review the normal curve table. Find the probability that a number drawn from a standard normal distribution will be less than 1.

Now do this with the pnorm() function.

## Solution

pnorm(1)
##  0.8413447

## From Probability to Z-value

Find the 70th percentile of the standard normal Random Variable.

Use the table.

## Now use the qnorm() function.

qnorm(.7)
##  0.5244005