Definition
A population is the complete set of things, or the ongoing process that produces outcomes, about which a study wants to reach a conclusion. A sample is the part of the population that the study actually observed. A number that describes the population, such as its mean (the average), is called a parameter. The same calculation applied to the sample gives a statistic, which serves as an estimate of the parameter. The difference that matters: the conclusion is about the population, but the evidence comes only from the sample.
The idea
A timing log holds 1,000 rows, one response time §9.32 per request, all from one circuit board during one run, meaning one period of operation after switch-on. The rows could be asked to speak for four different things: those 1,000 requests and nothing more, future requests on the same board, future runs of that board, or every board of that model. The numbers in the log are the same in all four cases. What changes is how far the conclusion reaches beyond the rows, and so how much has to be assumed.
Tasting soup gives the picture. One spoonful tells the cook about the whole pot if the pot was stirred first, because then every part of the soup had the same chance of ending up in the spoon. A spoonful from an unstirred pot describes only the top layer, and a second spoonful from the same place does not help. The picture stops being accurate in two respects. A pot is finite, whereas many engineering populations are processes that keep producing new outcomes, such as all future requests. And real data are layered: a few boards, several runs of each board, many requests in each run.
How it works
Reading a data set as a sample takes four steps.
Name the population. It is either a finite set whose members could be listed, such as the 400 boards of one production batch, or a process, such as the requests that one board will serve under a stated workload. A process is described by a probability distribution: the possible outcomes together with the probability of each.
Name the sampling unit, the thing that was selected: a board, a run, a request.
State how the units were selected. In a simple random sample of units, every set of units in the population is equally likely to be the sample. A convenience sample is whatever was at hand. A census observes every unit of a finite population.
Count the units at every level. Selecting 2 boards, starting each one 3 times and logging 500 requests per run gives runs and requests. For a claim about boards the sample size is 2.
Three different things separate a statistic from its parameter.
Sampling error is the chance difference that arises because only part of the population was observed. Its typical size shrinks as more units are selected at random.
Selection bias, in sampling also called sampling bias §14.31, is a systematic difference that arises when some units were more likely to be selected than others and the calculation does not correct for the unequal chances, or when some units could not be selected at all. A larger sample taken the same way does not remove it.
Measurement error is the difference between a recorded value and the true value for that unit. Even a census has it.
Worked example
A batch consists of four boards. Their true mean response times are 1, 1, 9 and 9 milliseconds (ms). The population is these four boards, and the parameter of interest is the mean over boards:
A tester measures the two boards already on the bench, which happen to be the two fast ones. The statistic is ms, which is 4 ms below the parameter. Logging 1,000 more requests on each of those boards makes the mean of each board more exact. It does not bring a slow board into the sample, so the answer stays near 1 ms.
Now select two of the four boards at random, so that each of the 6 possible pairs is equally likely. One pair holds both fast boards and has mean 1 ms. One pair holds both slow boards and has mean ms. The other four pairs hold one fast and one slow board and have mean ms. Averaged over the six pairs, the statistic is which equals the parameter. One random sample can still miss: 2 of the 6 pairs give 1 ms or 9 ms. But random selection guarantees that the misses average out to zero. The convenience sample has no such guarantee.
Stated precisely
Let a finite population consist of units with values . Its mean, a parameter, is ; the symbol is the Greek letter mu. A sample is a set of of these units. The sample mean §11.12, a statistic, is the sum of the values of the units in divided by ; write it . Under simple random sampling every possible set has the same probability, and then the average of over all possible samples equals exactly. A statistic whose average over all possible samples, each weighted by its probability, equals the parameter is called unbiased for the parameter.
More generally, let (pi) be the probability that unit ends up in the sample; the selection procedure fixes this number. If every is known and greater than zero, the weighted calculation in which means the sum over the units in the sample, is unbiased for . The rule is named after Horvitz and Thompson, who published it in 1952 [465]. Simple random sampling is the special case , in which equals . If for some unit, the data contain nothing about that unit, and no calculation recovers its value.
For a process, the population is a probability distribution and the sample is observations of it. The simplest model of such a sample adds two conditions, treated in the entry on independent and identically distributed samples §11.5: every observation is drawn from that same distribution, and knowing some observations does not change the probabilities for the others. The usual formulas for the uncertainty of an average are derived under both conditions. When observations depend on each other or their distribution changes, conclusions beyond the sample need a method that allows for that dependence or change. For dependence inside groups, one such method is the cluster bootstrap §11.21, which builds new data sets by drawing whole groups of related observations, such as all readings from one board, at random from the recorded ones.
Limits and common mistakes
A census removes sampling error only for the finite population that was counted. It does not remove measurement error, and it says nothing about a larger population.
Random test inputs are a sample of inputs, not of boards, runs or environments. Each kind of variation has to be sampled itself.
A sample of completed requests represents completed requests. If failed requests left no row, the population has silently changed to the requests that succeeded. This is survivorship bias §11.30.
A narrow population is legitimate: for a question about only the two boards on the bench, those boards are a census. How far a result carries beyond the sampled population is the separate question of external validity §11.44.
In statistics a sample is the whole set of observations: a log of 1,000 rows is one sample of size 1,000. Engineers also call a single reading a sample, as in 1,000 samples per second.
Questions answered
Are observations sampled devices, boots, sessions, updates, or events?
They are sampled at every level at which the study made a separate selection, and one log usually contains several of these levels, each nested in the one above. The levels named in the question are: a device, one physical unit; a boot, one run of a device from start-up to the next restart; a session, one continuous period of activity within a boot, such as one connection; an update, one installation of new software or settings; and an event, one occurrence that the device handles and records, such as one request.
The question therefore has one answer per level. For each level, state how many units were observed, how they were selected, and which population they stand for. A statement about devices in general rests on the number of devices selected, not on the number of events, because all events from one device share the peculiarities of that device.
Related entries: Estimand and estimator (§11.2), Experimental unit (§11.3), Observational unit (§11.4), External validity (§11.44), Independent and identically distributed samples (§11.5), Survivorship bias (§11.30), Sampling bias (§14.31). Further reading: [465].