Coding· RHomeworkPredict, observe, explainRecall with feedbackBefore teachingAccessibility not checkedPublished

Sample Size and the Sampling Distribution (R)

By Alexis Diamond · Statistics · Sampling distributions · Undergraduate · Simulation of a known property · version 6

Licence: CC BY 4.0

Share and present
Assumption ledger (7)
  • distributionThe population is 50,000 draws from a Normal distribution with mean 1 and standard deviation 1 (seed 1234). Its own mean is 1.0021, not exactly 1, because the population is itself a draw; that value, true_mean, is what the samples try to infer.
  • parameterThe sampling distributions use 1,000 samples each: of size 10 (seed 2345) and of size 100 (seed 3456), drawn with replacement. The interquartile ranges come out about 0.41 and 0.14, a ratio near the square root of 10 (about 3.16).
  • simplificationSampling is with replacement from a finite population, which stands in for sampling from a population too large to exhaust. The population is Normal; with a skewed population the spread shrinks with sample size in the same way, though the shape of the sampling distribution differs for small samples.
  • parameterThe code checks accept any correct loop, not just the seeded one: the spread of the 1,000 means must be within 0.05 of 1/√10 (n = 10) or 0.02 of 1/√100 (n = 100), and their average within the same margin of true_mean. Correct answers pass for every one of 200 other seeds tried; samples of the wrong size fail.
  • interpretationThis is the instructor's Forum code workbook with a 13-item list of corrections applied (comments fixed, a reference line, true_mean stored, replace = TRUE shown, no NULL default, a prediction prompt, seeds and preallocation, one overlaid plot of both sampling distributions, rewritten Question 10, and a new question on random sampling versus random assignment).
  • interpretationFour small additions beyond the list: Questions 1–3 are read-only setup cells, so later cells never find population missing; a short answer box under Question 5 for the written prediction; a guard line at the top of Question 9 that names the loops to run first; and ylim on the overlay so the taller n = 100 curve is not cut off at the top. The ??? blanks in Questions 4 and 6 are kept as written, so those cells give a parse error until filled in.
  • interpretationQuestions 12 and 13 are multiple choice with feedback shown as soon as an answer is chosen. They rest on the standard result that the standard deviation of the sample mean is σ/√n (exact here, since sampling is with replacement): it shrinks as n grows but never reaches zero, and 100 times the sample size gives one-tenth the spread. A simulation with this population gave a ratio of 9.8 for n = 10 versus n = 1,000.
Checks Breakout ✓ · Code not checked · Accessibility ✓

Breakout check

✓ Ready for breakouts: every control we tried showed teammates the same thing.

Code checks

Not checked yet.

Cite this · History

Cite this

Alexis Diamond (2026). Sample Size and the Sampling Distribution (R) [Interactive model], version 6. Ideas at Play. https://ideasatplay.org/play/sample-size-and-the-sampling-distribution-r-a3ffe5?v=6 (CC BY 4.0)

History

  1. v6Instructor freeze now works inside the platform's frame: typing CS350 and pressing Enter or clicking Freeze no longer relies on form submission, which the sandbox blocks. (edited, Nov 1, 2026)current
  2. v5Adds Questions 12 and 13: multiple choice on how sample size changes the spread of the sampling distribution, qualitatively and for a 100-fold increase. (edited, Nov 1, 2026)View
  3. v4Question 1: a sentence above the code says rnorm() is called with a mean of 1 (and a standard deviation of 1). (edited, Nov 1, 2026)View
  4. v3Question 10(b) reworded for clarity: the point, then what the unchanged centre and shrinking spread tell you. (edited, Nov 1, 2026)View
  5. v2Question 9: the check that the loops have run is now a plain if/stop line with a comment above it. (edited, Nov 1, 2026)View
  6. v1Imported; lineage before import is not available. (imported, Nov 1, 2026)View
Report this artifact

Reports are anonymous. The artifact stays up until we've checked it.

Comments

No comments yet.

Sign in to comment or like.

Anything wrong with this page? Submit feedback