Written and maintained by CASRAI Editorial Board
Last updated
Sampling with replacement means that each unit you draw is put back before the next draw, so the same unit can be selected more than once. Every draw is made from the same full population, which makes the draws independent. This guide gives the definition, the counting formula, a worked example with the arithmetic shown, the contrast with sampling without replacement, and the code for R, Python and Excel. One point is worth knowing up front: base R’s sample() samples without replacement unless you ask otherwise.
What is sampling with replacement?
In sampling with replacement, a unit is selected, recorded and returned to the population before the next unit is selected. Because the population never shrinks, the chance of selecting any particular unit is the same on every draw, and the outcome of one draw tells you nothing about the next. A unit may appear several times in the sample, or not at all. Sampling without replacement is the opposite scheme: a selected unit is not returned, so it can appear at most once. For the standard survey version of that scheme, see simple random sampling.
Formula: how many samples are possible?
Let N be the number of units in the population and n the number of draws. Each draw has N possible outcomes, and the draws do not restrict one another, so:
- Ordered samples with replacement: Nn
- Ordered samples without replacement: N! / (N − n)! = N × (N − 1) × … × (N − n + 1)
- Probability that a specific unit is chosen on any one draw with replacement: 1 / N
- Probability that a specific unit is never chosen in n draws with replacement: (1 − 1/N)n
Here N is the population size, n is the sample size (number of draws), and the exclamation mark denotes the factorial. For N = 3 units A, B and C and n = 2 draws, with replacement gives 32 = 9 ordered samples (AA, AB, AC, BA, BB, BC, CA, CB, CC), while without replacement gives 3 × 2 = 6 (the three repeated pairs AA, BB and CC are impossible).
Worked example: two reds from an urn of 10
An urn holds 5 red and 5 blue marbles. You draw two and want the probability that both are red.
- With replacement: the first draw is red with probability 5/10 = 0.5. The marble goes back, so the second draw is again 5/10 = 0.5. Because the draws are independent, P(two reds) = 0.5 × 0.5 = 0.25.
- Without replacement: the first draw is red with probability 5/10. With one red removed, 4 reds remain among 9 marbles, so the second draw is 4/9. P(two reds) = 5/10 × 4/9 = 20/90 = 0.2222.
The two answers differ because removing a red marble makes a second red less likely. With replacement the result is a simple product, which is why it leads to the binomial model; without replacement the count of reds follows the hypergeometric distribution.
Sampling with replacement vs without replacement
| Feature | With replacement | Without replacement |
|---|---|---|
| Can a unit appear twice? | Yes | No |
| Draws independent? | Yes | No |
| Ordered samples (N = 3, n = 2) | 9 | 6 |
| P(two reds), 5 red and 5 blue, n = 2 | 0.25 | 0.2222 |
| Variance of the sample mean, population 2, 4, 6, 8 with n = 2 | 2.5 | 1.6667 |
The last row comes from enumerating every sample. The population 2, 4, 6, 8 has mean 5 and population variance σ² = (9 + 1 + 1 + 9) / 4 = 5. With replacement there are 16 ordered samples of size 2, and the variance of their means is σ² / n = 5 / 2 = 2.5. Without replacement there are 12 ordered samples, and the variance of their means is (σ² / n) × (N − n) / (N − 1) = 2.5 × 2/3 = 1.6667. The factor (N − n) / (N − 1) is the finite population correction; it approaches 1 when n is small relative to N, which is why the two schemes give almost the same answers for large populations. That is the reasoning behind the sample-size rule discussed in the 10% condition.
Interpretation: what the result means
| What you see | How to read it |
|---|---|
| A unit appears twice in the sample | Expected under replacement; it is not an error and not a duplicate record. |
| Sample is larger than the population | Possible only with replacement (for example 12 draws from 10 units). |
| Some population units never appear | Expected: with n = N = 10, each unit is missing with probability 0.910 = 0.3487, so about 65% of units (1 − 0.3487 = 0.6513) appear at least once. |
| Results differ slightly from a without-replacement run | Expected when the sample is a large share of the population; negligible when it is a small share. |
The missing-unit figure matters for the bootstrap. The NIST/SEMATECH e-Handbook describes a bootstrap subsample as generated “with replacement so that any data point can be sampled multiple times or not sampled at all.” As n grows with N = n, (1 − 1/n)n tends to 0.3679 (the value of 1/e): at n = 10 it is 0.3487, at n = 100 it is 0.3660 and at n = 1,000 it is 0.3677. So a bootstrap resample typically contains about 63% of the distinct original observations. See bootstrapping in statistics for how this is used.
Assumptions and common mistakes
- Assuming software samples with replacement by default. R’s
sample(x, size, replace = FALSE, prob = NULL)defaults toreplace = FALSE. Python’srandom.sample()is documented as “random sampling without replacement”, whilerandom.choices()returns a list chosen “with replacement”. Choosing the wrong function changes the scheme silently. - Using the without-replacement formula for with-replacement draws (5/10 × 4/9 instead of 5/10 × 5/10), or the reverse.
- Treating without-replacement draws as independent. They are not, although the dependence is slight when the sample is a small fraction of the population.
- Not reporting the scheme. A reader cannot reproduce or evaluate the analysis if the method states only that a random sample was taken.
- Counting repeated units as independent people. If a person can be drawn twice, the sample contains fewer distinct people than draws.
How to report it
State the scheme, the population, the sample size and the software. An example for a methods section: “We drew 1,000 bootstrap resamples, each of size n = 120, by sampling observations with replacement from the original data (R, sample() with replace = TRUE, seed 2026).” Report the seed so the draw can be repeated, and report the number of draws, which is separate from the sample size. If your journal or department follows APA style, check the current edition for how to format statistical symbols and numbers in the same sentence.
How to sample with replacement in R, Python or Excel
R
set.seed(2026)
x = c(2, 4, 6, 8)
sample(x, size = 6, replace = TRUE) # with replacement; size may exceed length(x)
sample(x, size = 4) # replace = FALSE by default: without replacement
For random numbers more generally, see random number generation in R.
Python
import random
random.seed(2026)
pop = [2, 4, 6, 8]
random.choices(pop, k=6) # with replacement
random.sample(pop, k=4) # without replacement (unique positions)
Excel
Put the population in A2:A11 and fill this formula down as many rows as you have draws: =INDEX($A$2:$A$11, RANDBETWEEN(1, 10)). Each row picks a position from 1 to 10 independently of the other rows, so the same unit can be chosen again, which is sampling with replacement. The values change on every recalculation, so copy and paste them as values to freeze a sample.
Frequently asked questions
Can the same unit be selected twice?
Yes, with replacement. After each draw the unit goes back into the population, so it can be drawn again on any later draw.
Do the draws stay independent?
Yes. The population is identical at every draw, so the probability of each outcome is unchanged by earlier draws. Without replacement the draws are dependent, as the 5/10 × 4/9 calculation above shows.
Is sampling with replacement the same as the bootstrap?
No, but the bootstrap relies on it. A bootstrap resample is a sample of the same size as the data drawn with replacement from the data itself. Sampling with replacement is the general scheme; the bootstrap is one use of it. The bootstrap in R guide shows the code.
Which scheme do surveys use?
Surveys usually sample without replacement, because interviewing the same person twice adds no new information. The with-replacement model is still used as a simplifying approximation when the sample is a small share of the population, and it underlies the binomial experiment.
When does the difference between the two schemes stop mattering?
When n is small relative to N. The finite population correction (N − n) / (N − 1) is then close to 1. In the example above, with N = 4 and n = 2 it is 2/3, which is a large correction; with N = 1,000 and n = 10 it is 990/999 = 0.991.
Sources
- NIST/SEMATECH e-Handbook of Statistical Methods, “Bootstrap Plot”: itl.nist.gov/div898/handbook/eda/section3/bootplot.htm (checked 2026-10-29).
- R Documentation,
base::sample: stat.ethz.ch/R-manual/R-devel/library/base/html/sample.html (checked 2026-10-29). - Python Software Foundation,
randommodule documentation: docs.python.org/3/library/random.html (checked 2026-10-29).








