load("~/Dropbox/RProjects/Math 146 Notes/cdc.Rdata")
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)
## [1] 0.74417
Use the cdc dataset. Find the 60th percentile of the height values.
quantile(cdc$height,.6)
## 60%
## 68
What is the percentile rank of 70 inches in the distribution of heights in cdc?
mean(cdc$height < 70)
## [1] 0.6878
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.
pnorm(1)
## [1] 0.8413447
Find the 70th percentile of the standard normal Random Variable.
Use the table.
qnorm(.7)
## [1] 0.5244005