Section 4.3: Random Variables (cont.)

Example: Teen drivers

What is the probability that the proportion of SRS of 500 teen drivers who text while driving is within .03 (3%) of .26?

pdist("norm", mean=.26, sd=.0196, c(.23, .29))

## [1] 0.06293263 0.93706737

So the probability is .874.

Section 4.4: Means and Variances of Random Variables

Load the data set Birthdays from the MosaicData package. Note that the data set is really large with 372864 observations.

birthdays<-Birthdays

Find the mean number of births per day using the entire data set:

mean(~births, data=birthdays)
## [1] 189.0409

Now, take random samples of various sizes and compute the sample mean.

mean(~births,data=sample(birthdays, 10))
## [1] 168.7
mean(~births,data=sample(birthdays, 10))
## [1] 151
mean(~births,data=sample(birthdays, 10))
## [1] 223.3
mean(~births,data=sample(birthdays, 100))
## [1] 174.98
mean(~births,data=sample(birthdays, 100))
## [1] 195.04
mean(~births,data=sample(birthdays, 100))
## [1] 198.25
mean(~births,data=sample(birthdays, 1000))
## [1] 189.67
mean(~births,data=sample(birthdays, 1000))
## [1] 188.152
mean(~births,data=sample(birthdays, 1000))
## [1] 202.809
mean(~births,data=sample(birthdays, 10000))
## [1] 187.4937
mean(~births,data=sample(birthdays, 10000))
## [1] 190.13
mean(~births,data=sample(birthdays, 10000))
## [1] 188.4456
mean(~births,data=sample(birthdays, 10000))
## [1] 186.5359
mean(~births,data=sample(birthdays, 10000))
## [1] 189.248

Notice, that the variability decreases and the sample mean gets closer to the mean of the entire data set as the size of the sample increases.