Teaching Dataset Generator (with Answer Key)

Generate a simulated dataset for classroom practice: two groups, ANOVA, correlation, or pre-post with control, with the effect size you choose, a reproducible seed, and an answer key with the real statistics.

A simulated dataset with the statistical property you choose: Cohen’s d, η², or Pearson’s r. With a reproducible seed so the whole class works from the same data, plus an answer key with the real statistics students will get.

The four designs

Plus a seed, fixed (42) or random. The same seed always produces the same dataset: give it to your class so everyone works from the same data.

What you get

What the page shows on load (two groups, n = 30, d = 0.5, seed 42)

Statement for students: A simulated dataset of 60 participants (n = 30 per group) comparing two independent groups (A and B) on a continuous variable. Compute the mean and standard deviation of each group and Cohen’s d for the difference between them; interpret the effect size using Cohen’s (1988) criteria. Seed used to generate this data: 42.

Answer key (for instructors): With seed 42: group A (n = 30) M = -0.25, SD = 1.07; group B (n = 30) M = 0.41, SD = 1.04. The SAMPLE Cohen’s d students will obtain is d = 0.62 (the population target was d = 0.50); the gap between them is the sampling variability expected with n = 30 per group, not a flaw in the generator.

And with a real study?

This dataset is simulated: the d, η², or r your students obtain depends on the numbers YOU chose when generating it. In a real study nobody knows the population effect in advance; there, what gets computed is the pre-post effect size with a control group (Morris’s d) from real means and standard deviations, not from a pre-set target.

If your pre-post design uses a 0-to-100 test (typical of an educational assessment), the Hake normalized gain is the metric your field expects, an alternative to d when the test’s ceiling matters.

Worked example

Design "Two independent groups", n = 30 per group, target Cohen’s d = 0.5 (medium effect per Cohen, 1988), seed = 42. Being deterministic, anyone who enters exactly these same numbers gets EXACTLY this same dataset, in any browser.

Verified by running the library with node: group A (n = 30) comes out with M = −0.25, SD = 1.07; group B (n = 30), with M = 0.41, SD = 1.04. The SAMPLE Cohen’s d of that specific dataset is: d = (0.410 − (−0.248)) / 1.054 = 0.658 / 1.054 = 0.62.

With d = 0.62 students obtain a large effect per Cohen (1988), even though the dataset was generated with a target of d = 0.50 (medium): that is exactly the pedagogical point of this tool — with n = 30 per group, that kind of gap between the population effect and the sample effect of ONE specific study is the norm, not the exception, and it is the first thing worth discussing in class before looking at any significance table.

Formulas and methodology

Seed and number generator: mulberry32 (public domain), a 32-bit generator with a single integer of state. Same seed → same numbers, always: this is what lets you share "the same" dataset with a single number, and why Math.random() (which takes no seed) is never used as the sole source.

Normal values: Box-Muller transform (Box & Muller, 1958) from two uniforms: z₀ = √(−2·ln u₁)·cos(2π·u₂), z₁ = √(−2·ln u₁)·sin(2π·u₂).

(a) Two groups: group A ~ N(0,1), group B ~ N(d,1). With SD = 1 in both, the population mean difference IS Cohen’s d (Cohen, 1988, ch. 2).

(b) Multi-group ANOVA: k equally spaced means, symmetric around 0, calibrated with Cohen’s f (Cohen, 1988, ch. 8): f = √(η²/(1−η²)), c = f·√(12/(k²−1)), meanᵢ = c·(i−(k−1)/2). The constant c follows from the population variance (divisor k) of k equally spaced points with step c being c²·(k²−1)/12; setting it equal to f² and solving gives c.

(c) Correlation: Y = r·X + √(1−r²)·Z with X, Z ~ N(0,1) independent: the standard transform for a bivariate pair with an exact population correlation r.

(d) Pre-post with control: the "two groups" technique is applied to the GAIN (post−pre) instead of to the raw score: control gain ~ N(0,1), treatment gain ~ N(d,1). The pretest is generated separately, ~N(0,1) in both groups, and posttest = pretest + gain; this also produces a pre-post correlation of 1/√2 ≈ .71, a plausible test-retest reliability value with no extra parameter needed.

References

Frequently asked questions

Why do I need a seed? Isn’t "random" enough?

Because "truly random" cannot be shared: if each student generates their own dataset with Math.random(), each one gets different numbers and you cannot put a single solution on the board. With a fixed seed (e.g. 42), the whole class types the same number and gets EXACTLY the same dataset, byte for byte.

Why isn’t the resulting effect exactly what I asked for?

Because what you ask for is the POPULATION effect (the one in the mathematical formula) and what your students compute is the SAMPLE effect (the one for THIS specific dataset, with THIS n). They differ by definition: any sample departs somewhat from its population, and more so with small n. Raise n and you will see the sample value move closer to the target — that is precisely the underlying lesson of this tool.

Can I open the CSV in SPSS, jamovi, or Excel?

Yes, the CSV is standard plain text and opens directly. The values are in standardized units (mean and SD close to 0 and 1): treat them as scores on a fictional scale, the same way any textbook exercise uses round numbers without that taking anything away from the analysis your students have to perform.

Which design do I choose for what I’m teaching?

Independent-samples t-test → "Two groups"; one-way ANOVA → "More than two groups"; Pearson correlation or simple linear regression → "Correlation"; an educational quasi-experiment with a control group (the typical design of an education dissertation) → "Pre-post with a control group". The four designs cover exactly what most introductory methodology courses need.

You may also be interested in

Home · Contact for a quote