Toolvito

Calculates on this device. File exports run online.

Random Sampling Tool

Paste a list or give a range of numbers and draw a simple random sample, with or without replacement. Draw every k-th unit after a random start, split a sample over strata in proportion to their sizes (or equally, or by Neyman allocation), or draw clusters and then units in them. Every sample shows its seed and method, so anyone can draw the same sample again. The tool also works out the sample size you need for a survey and counts the possible samples.

Enter your values

Items from a list or numbers from a range, with or without replacement, with a seed.

Your values

One item on each line: names, IDs, addresses …

Any whole number. Leave it empty for a new random seed.

Your values are worked out in this browser. They are not sent to a server.

Your result will show here

Fill in the values, then choose the button below them.

Sample the rows of a large file

Sample the rows of a large file

Choose a CSV, Excel, JSON Lines or Parquet file of up to 1 GB. The server draws n rows at random (reservoir sampling), a percent of the rows (each row kept with that chance), every k-th row, or up to n rows from each value of a group column, with DuckDB’s own seeded sampling: the same seed gives the same rows again. The rows keep their file order.

Or drop files here. CSV, TSV, TAB, TXT, JSON, JSONL, NDJSON, PARQUET, XLSX, XML, YAML, YML, TOML, PLIST, GED, XSD or DTD, up to 20 files, 1 GB each at most.

    More options

    Lists above stay in your browser. When you use this box, the file you choose is sent to the Toolvito server. Download the result within one hour after the job finishes. Choose Delete files now to request earlier removal. The hourly cleanup normally removes files within one to two hours after completion.

    How to use it

    1. Choose Simple random sample, paste your list (one item on each line) or give a range, set the sample size and press Draw the sample.
    2. Keep the seed shown with the result: the same seed, list and size always give the same sample. Leave the seed empty to get a new one.
    3. For groups, choose Stratified sample and give the size of each group; for schools, villages or batches, choose Two-stage (cluster) sample.
    4. Choose Sample size to find how many people or items to sample for a margin of error.

    The method, stated

    • Random numbers come from xoshiro128**, seeded by SplitMix32 from the seed. A whole number from 0 to m − 1 is drawn by rejecting values above the largest multiple of m, so there is no bias.
    • Without replacement the sample is a partial Fisher–Yates shuffle: every set of n items is equally likely. With replacement each draw is independent.
    • Systematic: interval k = N ÷ n (a fraction is kept) and a random start between 0 and k; units ⌊start + i × k⌋ + 1.
    • Stratified: n is split by largest remainders, never above a stratum’s size; each stratum is sampled with the seed plus its number.
    • This generator is made for repeatable samples, not for secrets: do not use it for passwords or draws where someone could profit from guessing the seed.

    Sample size

    For a share: n₀ = z² × p × (1 − p) ÷ e²; for a mean: n₀ = (z × σ ÷ e)². With a population of N, n = n₀ ÷ (1 + (n₀ − 1) ÷ N). At 95% confidence and ±5 points, a share needs 385 people from a large population.

    Related tools