Plot a uniform distribution, to find the probability that a randomly selected number from 0 to 1 is between 0.3 and 0.7.
pdist("unif", min=0, max=1, c(0.3, 0.7))
## [1] 0.3 0.7
We can divide the area under the curve into as many pieces as we want:
pdist("unif", min=0, max=1, c(0.1, 0.3, 0.7, 0.9))
## [1] 0.1 0.3 0.7 0.9
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.
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] 304.5
mean(~births,data=sample(birthdays, 10))
## [1] 133.2
mean(~births,data=sample(birthdays, 10))
## [1] 375.2
mean(~births,data=sample(birthdays, 100))
## [1] 162.46
mean(~births,data=sample(birthdays, 100))
## [1] 188.52
mean(~births,data=sample(birthdays, 100))
## [1] 194.38
mean(~births,data=sample(birthdays, 1000))
## [1] 199.17
mean(~births,data=sample(birthdays, 1000))
## [1] 192.935
mean(~births,data=sample(birthdays, 1000))
## [1] 196.348
mean(~births,data=sample(birthdays, 10000))
## [1] 189.6752
mean(~births,data=sample(birthdays, 10000))
## [1] 189.6124
mean(~births,data=sample(birthdays, 10000))
## [1] 192.3888
mean(~births,data=sample(birthdays, 10000))
## [1] 189.0037
mean(~births,data=sample(birthdays, 10000))
## [1] 187.5961
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.