Skip to main content

Introduction to Data Science Version 3

Chapter 8 Sample in a Jar

Sampling distributions are the conceptual key to statistical inference. Many approaches to understanding sampling distributions use examples of drawing marbles or gumballs from a large jar to illustrate the influences of randomness on sampling. Using the list of U.S. states illustrates how a non-normal distribution nonetheless has a normal sampling distribution of means.

Sources.

R Functions Used in This Chapter.

read.DIF() - Reads data in interchange format
read.table() - Reads data table from external source
hist() - Produces a histogram graphic
length() - The number of elements in a vector
mean() - Calculate arithmetic mean
median() - Locate the median
mode() - Tells the data type/mode of a data object (Note: This is NOT the statistical mode)
quantile() - Calculates cut points based on percents/proportions
replicate() - Runs an expression/calculation many times
sample() - Chooses elements at random from a vector
sd() - Calculate the sample standard deviation
sqrt() - Calculates square root
summary() - Summarizes contents of a vector
var() - Calculate the sample variance

Test Yourself.

See the Chapter Challenge exercise above.

If All Else Fails.

In case you have difficulty with the read.DIF() or read.table() functions, the code shown below can be copied and pasted (or, in the worst case scenario, typed) into the R console to create the data set used in this chapter.
V1 <- c(4779736,710231,6392017,2915918,37253956,
5029196,3574097,897934,601723,18801310,9687653,
1360301,1567582,12830632,6483802,3046355,2853118,
4339367,4533372,1328361,5773552,6547629,9883640,
5303925,2967297,5988927,989415,1826341,2700551,
1316470,8791894,2059179,19378102,9535483,672591,
11536504,3751351,3831074,12702379,1052567,
4625364,814180,6346105,25145561,2763885,625741,
8001024,6724540,1852994,5686986,563626)
USstatePops <- data.frame(V1)