Sampling Methods

by Linda Westfall

A Software Quality Engineers (SQEs) needs to know when and how to use different sampling techniques in order to effectively use sampling during product and project management, audits, testing, product acceptance. and other quality activities.

When the set of all possible items in a population is very large, it may be too costly or time-consuming to do a comprehensive analysis of all of the items. For example, during an audit, there is just not enough time to talk to every auditee, witness every process step, or look at every quality record. If the customer base is large, it may be too costly to survey all the customers to determine their satisfaction level. Evaluating or estimating attributes or characteristics of the entire system, process, product, or project through a representative sample can be more efficient while still providing the required information. To legitimately be able to use a sample to extrapolate the results to the whole population requires the use of one of four statistical sampling methods. 

Random sampling: The first statistical sampling method is simple random sampling. In this method, each item in the population has the same probability of being selected as part of the sample as any other item. For example, a tester could randomly select 5 inputs to a test case from the population of all possible valid inputs within a range of 1-100 to use during test execution. To do this, the tester could use a random number generator or simply put each number from 1-100 on a slip of paper in a hat, mixing them up and drawing out 5 numbers. Random sampling can be done with or without replacement. If it is done without replacement, an item is not returned to the population after it is selected and thus can only occur once in the sample.

Systematic sampling: Systematic sampling is another statistical sampling method. In this method, every nth element from the list is selected as the sample, starting with a sample element n randomly selected from the first k elements. For example, if the population has 1000 elements and a sample size of 100 is needed, then k would be 1000/100 = 10. If number 7 is randomly selected from the first ten elements on the list, the sample would continue down the list selecting the 7th element from each group of ten elements. Care must be taken when using systematic sampling to ensure that the original population list has not been ordered in a way that introduced any non-random factors into the sampling.   An example of systematic sampling would be if the auditor of the acceptance test process selected the 14th acceptance test case out of the first 20 test cases in a random list of all acceptance test cases to retest during the audit process. The auditor would then keep adding twenty and select the 34th test case, 54th test case, 74th test case, and so on to retest until the end of the list is reached.

Stratified sampling: The statistical sampling method called stratified sampling is used when representatives from each subgroup within the population need to be represented in the sample. The first step in stratified sampling is to divide the population into subgroups (strata) based on mutually exclusive criteria. Random or systematic samples are then taken from each subgroup. The sampling fraction for each subgroup may be taken in the same proportion as the subgroup has in the population. For example, if the person conducting a customer satisfaction survey selected random customers from each customer type in proportion to the number of customers of that type in the population. For example, if 40 samples are to be selected, and 10% of the customers are managers, 60% are users, 25% are operators, and 5% are database administrators, then 4 managers, 24 uses, 10 operators, and 2 administrators would be randomly selected. Stratified sampling can also sample an equal number of items from each subgroup. For example, a development lead randomly selected three modules out of each programming language used to examine against the coding standard. 

Cluster samplingThe fourth statistical sampling method is called cluster sampling, also called block sampling. In cluster sampling, the population that is being sampled is divided into groups called clusters. Instead of these subgroups being homogeneous based on selected criteria as in stratified sampling, a cluster is as heterogeneous as possible to match the population. A random sample is then taken from within one or more selected clusters. For example, if an organization has 30 small projects currently under development, an auditor looking for compliance to the coding standard might use cluster sampling to randomly select 4 of those projects as representatives for the audit and then randomly sample code modules for auditing from just those 4 projects. Cluster sampling can tell us a lot about that particular cluster, but unless the clusters are selected randomly, and a lot of clusters are sampled, generalizations cannot always be made about the entire population. For example, random sampling from all the source code modules written during the previous week, or all the modules in a particular subsystem, or all modules written in a particular language may cause biases to enter the sample that would not allow statistically valid generalization. 

Haphazard samplingThere are also other types of sampling that, while non-statistical (information about the entire population cannot be extrapolated from the sample), may still provide useful information. In haphazard sampling, samples are selected based on convenience but preferably should still be chosen as randomly as possible. For example, the auditor may ask to see a list of all of the source code modules and then closes his eyes and points at the list to select a module to audit. Or the auditor could grab one of the listing binders off the shelf, flip through it and “randomly” stop on a module to audit. The haphazard sampling is usually, quicker and uses smaller sample sizes than other sampling techniques. The main disadvantage of haphazard sampling is that since it is not statistically based, generalizations about the total population should be made with extreme caution.

Judgemental samplingAnother non-statistical sampling method is judgmental sampling. In judgmental sampling, the person doing the sample uses his/her knowledge or experience to select the items to be sampled. For example, based on experience, an auditor may know which types of items are more apt to have nonconformances or which types of items have had problems in the past, or which items are a higher risk to the organization. In another example, the acceptance tester might select test cases that exercise the most complex features, mission-critical functions, or most used sections of the software.

Click Here to Download this Article

The Westfall Team Posts Metrics, Measures & Analytical Methods Resources.

These resources are free to anyone who wants to read or download them. Subscribe to the Software Excellence Academy to be notified when new resources are added.