Random Sample Generator
Draw a simple, systematic or stratified random sample from a number range or your own list
[ Random Sample Generator - Quick Summary ]
What: Draws a random sample of up to 10,000 units from a number range (for example 1 to 5,000) or from a pasted list of up to 10,000 lines. Four methods: simple random sampling, sampling with replacement, systematic sampling and stratified sampling with proportional or equal allocation.
When to use: Picking survey respondents, audit samples of invoices or records, quality-control checks, selecting participants for a study, classroom statistics exercises, A/B test groups.
Example: Population 1-500, sample 5 → 2, 185, 335, 355, 416
Important: Each method shows what was done (sampling fraction, interval and random start, sample per group), so you can document the sample in a report.
Our random sample generator selects a statistically sound sample in one click. Enter a population as a number range (record IDs, row numbers, invoice numbers) or paste a list of names or items, set the sample size and choose a method: simple random sampling (every unit equally likely, no repeats), sampling with replacement, systematic sampling (random start, then every k-th unit) or stratified random sampling (a separate simple random sample inside each group, sized proportionally or equally). The result lists the selected units with their position in the population, plus the sampling fraction and the per-group breakdown. Export to text, CSV or JSON. Free, no signup.
What is a Random Sample?
A random sample is a subset of a population chosen by chance, so that the people or items you study represent the whole group. In a simple random sample, every unit has the same probability of selection and every possible sample of that size is equally likely - the basis of most statistical inference.
When the population has groups that must all be represented (departments, regions, age bands), a stratified random sample draws a simple random sample inside each group. Systematic sampling is a quicker alternative for ordered lists: pick a random starting point, then take every k-th unit.
Sampling Methods
Simple Random Sampling (without replacement)
Sampling With Replacement
Systematic Sampling
Stratified Random Sampling
item, group (or tab-separated, straight from a spreadsheet). Proportional allocation gives each group a share of the sample equal to its share of the population, rounded with the largest-remainder method so the total is exactly n. Equal allocation gives every group the same number; a group smaller than its share contributes all its units and the rest goes to the other groups.
Population as a Range or a List
How to Draw a Random Sample
[STEP 1] Choose a Method
Simple, with replacement, systematic or stratified.
[STEP 1] Define the Population
Enter a number range or paste your list. For stratified sampling, add the group after each item.
[STEP 1] Draw and Export
Set the sample size and click "Draw Sample". Keep it sorted in population order or in draw order, then copy or export to CSV.
Common Uses for Random Sampling
- › Surveys: Choose which customers or employees receive a questionnaire
- › Audits: Select invoices, expense claims or transactions to review
- › Quality Control: Pick units from a production batch for inspection
- › Research: Recruit study participants from a sampling frame
- › Teaching Statistics: Show how simple, systematic and stratified samples differ on the same population
- › Data Work: Pull a random subset of rows to check a large dataset by hand
Random Sampling Best Practices
- _ Make sure the population list (the sampling frame) is complete before you sample
- _ Use stratified sampling when small groups must be represented
- _ Avoid systematic sampling on lists sorted in a repeating pattern
- _ Record the method, population size and sample size alongside your results (export JSON keeps them)
- _ Decide the sample size before drawing, and do not redraw until you like the result
Technical Implementation
All selections use PHP's random_int(), which draws from the operating system's secure random source. Simple samples use a partial Fisher-Yates shuffle (or, for small samples from very large ranges, rejection of repeats), which makes every subset of size n equally likely.
// Simple random sample: partial Fisher-Yates over positions 1..N
for ($i = 0; $i < $n; $i++) {
$j = random_int($i, $N - 1);
[$pool[$i], $pool[$j]] = [$pool[$j], $pool[$i]];
}
$sample = array_slice($pool, 0, $n);
// Systematic: k = floor(N / n), random start r in 1..k
$sample = [r, r + k, r + 2k, ..., r + (n - 1)k];
// Stratified, proportional: n_h = n * N_h / N, largest remainder
// so that the group samples add up to exactly n
API Access for Developers
Frequently Asked Questions
What is the difference between simple and stratified random sampling? ▶
Sampling with or without replacement - which should I use? ▶
How is the systematic sampling interval chosen? ▶
How big can the population and the sample be? ▶
How do I sample rows from Excel or Google Sheets? ▶
Is my list stored? ▶
[ HOW TO CITE THIS PAGE ]
Generate-Random.org. (2026). Random Sample Generator. Retrieved from https://generate-random.org/random-sample
Random Sample Generator - Generate-Random.org (https://generate-random.org/random-sample)