Random Dataset Generator
Generate practice data for a statistics class in seconds: one variable, two variables with the correlation you choose, or groups with different means. Every dataset is built from a seed you can see and reuse, with the sample statistics shown, and downloads as a CSV for Excel, R, SPSS or Python. Runs in your browser — nothing is uploaded. Free, no sign-up.
Between −1 and 1, not including either end.
From 3 to 10,000 rows in all.
The same seed and settings always give the same data. Any text works.
Rescales the draws so the sample means, SDs and correlation equal what you typed. Handy for a clean textbook example; real samples never match exactly.
Your dataset
50 rows and 2 columns. Seed: 2024.
What the sample looks like
| Variable | n | Mean | SD | Min | Max |
|---|---|---|---|---|---|
| study_hours | 50 | 10.34 | 3.83 | 1.40 | 22.46 |
| exam_score | 50 | 70.14 | 10.19 | 47.11 | 94.85 |
You aimed for r = 0.600; this sample's correlation is r = 0.729. Samples vary around the target — tick the exact option for a sample that hits it.
Preview
| study_hours | exam_score |
|---|---|
| 15.08 | 69.94 |
| 11.80 | 74.82 |
| 8.76 | 57.23 |
| 5.91 | 54.44 |
| 22.46 | 94.85 |
| 13.26 | 80.81 |
| 9.66 | 65.79 |
| 14.35 | 76.85 |
| 8.07 | 65.00 |
| 7.56 | 66.02 |
Made in your browser from the seed; nothing is uploaded. Pseudo-random, for practice and demonstrations — not for security or for research claims.
How to Use the Random Dataset Generator
- 1. Choose the kind of data. Two correlated variables for correlation and regression practice, groups with different means for t-tests and ANOVA, or one variable for descriptive statistics and histograms.
- 2. Set the numbers. Names, means, standard deviations and — for a pair — the correlation you want. Choose the number of rows and the decimal places.
- 3. Read the sample statistics. The table shows what this particular sample actually looks like, next to the settings you asked for.
- 4. Download or copy the CSV. Open it in a spreadsheet or statistics package. The seed reproduces the exact same data later; "New random seed" gives a fresh dataset.
How the Data Are Made
Everything starts from a seed: your seed text goes through a fixed hash into the sfc32 pseudo-random generator, so the same seed and settings always produce the same numbers on any device. Normal values come from the Box–Muller transform, skewed ones from the exponential distribution by inversion, and groups are normal samples around the means you give.
Correlated pairs by the Cholesky method
To get two variables with correlation r, the generator draws two independent standard normal values z₁ and z₂ for each row. It sets x = μₓ + σₓ·z₁ and y = μᵧ + σᵧ·(r·z₁ + √(1 − r²)·z₂). The factors r and √(1 − r²) are the entries of the Cholesky factor of the correlation matrix [[1, r], [r, 1]], and they make the population correlation of x and y equal r exactly.
A population correlation is not a sample correlation, though. With 50 rows the sample r varies around the target by roughly ±0.1, just as it would in a real study. If you need a sample that hits the target — for a textbook example or to check software — tick the exact option. It centres and rescales the draws and removes any chance correlation between z₁ and z₂ (Gram–Schmidt), so the sample means, SDs and r equal your settings.
Worked Example: Study Hours and Exam Scores
The default settings ask for 50 students, study hours with mean 10 and SD 3, exam scores with mean 70 and SD 10, and a correlation of 0.6, with seed 2024. The sample that results has study hours with mean 10.34 and SD 3.83 (range 1.40 to 22.46) and exam scores with mean 70.14 and SD 10.19. Its correlation is r = 0.729 — higher than the 0.6 aimed for, which is ordinary sampling variation at n = 50.
With the exact option the same seed gives means of 10 and 70, SDs of 3 and 10 and r = 0.600 to the last digit. That sample suits a clean demonstration; the first suits teaching the idea that estimates wobble. Run either through the Correlation Calculator or the Linear Regression Calculator to see what a class would find.
Synthetic data is not collected data
Use generated datasets for practice, demonstrations and testing analyses. Never present them as observations from a real sample: reporting made-up data as results is research misconduct. The generator is pseudo-random and reproducible by design, so it is not suitable for security or for randomising participants — the Random Assignment Generator exists for that.
Frequently Asked Questions
- How do I generate data with a specific correlation?
- Draw two independent normal variables and mix them: y = r·z₁ + √(1 − r²)·z₂ gives a variable with correlation r with z₁. This is the Cholesky method, and it is what the generator does. Then rescale each variable to the mean and SD you want.
- Why is the correlation in my data not exactly what I asked for?
- The target is the correlation of the population the data are drawn from. Any finite sample has its own correlation, which varies around the target — with 50 rows by about 0.1. Tick the option to make the sample match exactly, or raise the number of rows to narrow the gap.
- Can I use generated data in my assignment or thesis?
- Yes for practice and for demonstrating a method, as long as you say the data are simulated. You must not present them as data you collected from real participants. For a method demonstration, state the seed and settings so anyone can reproduce your dataset.
- What does the seed do?
- It fixes the sequence of pseudo-random numbers. The same seed with the same settings gives identical data every time, in every browser, which makes examples shareable and results checkable. "New random seed" picks a different one using your browser's secure random generator.
- How do I open the CSV in Excel, R or SPSS?
- Download the file and open it in Excel, or read it with read.csv("random-dataset.csv") in R or pandas.read_csv in Python; SPSS imports CSV through File > Import Data. The first row holds the column names, and numbers use a period as the decimal mark whatever your page language.
- How many rows can I generate?
- Up to 10,000 in all — for groups, that is the number of groups times the rows per group. The preview shows the first 10 rows, but the download and the copy button contain every row.