Data Science Center

Twelve labs, thirty-plus interactive experiments, a project studio that analyses your files locally, a dataset library, learning paths and a specialised assistant.

41interactive experiments

Data Science Center

Statistics and Probability Lab

Distributions, sampling, the central limit theorem, intervals and tests.

  • 3lessons
  • 7experiments
  • 5terms
عربي

Scientific introduction

Inferential statistics lets us draw conclusions about a population from a sample while quantifying uncertainty. The experiments here re-sample thousands of times so you can watch estimators behave.

Learning objectives

  • Describe common distributions and their parameters
  • Explain the central limit theorem by simulation
  • Build and correctly interpret a confidence interval
  • Run a hypothesis test and read a p-value without fallacies
  • Understand simple linear regression and its limits

Topics

  • Distributions
  • Sampling
  • Confidence intervals
  • Hypothesis testing
  • Regression

Core concepts

Sampling distribution
The distribution of a statistic (such as the mean) across many samples from the same population.
Standard error
The standard deviation of an estimator's sampling distribution; σ/√n for the mean.
p-value
The probability of a result this extreme or more if the null hypothesis is true.
Confidence interval
An interval built by a procedure that covers the parameter in a stated share of repeated samples.
Effect size
The magnitude of a difference or relationship independent of sample size.

Theory

Sampling and the central limit theorem

The idea

When drawing sufficiently large random samples of size n from a population with finite mean μ and standard deviation σ, the distribution of sample means approaches a normal with mean μ and standard deviation σ/√n, even if the population is not normal.

The standard error falls with √n; doubling the precision needs four times the sample. How fast the approach happens depends on the population shape: heavily skewed distributions need larger samples.

Confidence intervals

Construction

For a population mean with unknown standard deviation: x̄ ± t·s/√n, with t from the t distribution on n-1 degrees of freedom.

Correct interpretation

A 95% interval means the procedure covers the true parameter in about 95% of repeated samples. It is wrong to say the parameter lies in this particular interval with 95% probability: the parameter is fixed and the interval is what varies. The interval narrows as n grows and widens as confidence rises.

Hypothesis tests and the p-value

The logic

Assume the null hypothesis H0 (no difference), compute a test statistic, then the p-value: the probability of a result this extreme or more if H0 is true.

What p is not

It is not the probability that H0 is true, nor the effect size, nor practical importance. Running many tests raises the chance of "significant" results by luck, so correct for multiple comparisons. Always report effect size and a confidence interval alongside p.

Worked examples

Reading a 95% interval

It does not mean the parameter lies inside this interval with 95% probability; it means the procedure, repeated, covers the parameter in about 95% of samples. The experiment shows this directly.

Interactive experiments

Beginner Synthetic data

Distribution simulator

Learning goal: See the shape of common distributions and the effect of their parameters.

Explanation and scientific documentation

A sample is drawn from a distribution you choose (normal, uniform, exponential, Poisson…) and compared with the theoretical density.

Data: A computer simulation with random numbers whose seed you can change; no real data.

Means and variances approach theoretical values as n grows (law of large numbers).

Limits: A simulation, not real data.

Beginner Synthetic data

Sampling simulator

Learning goal: Compare simple random, stratified and biased convenience sampling.

Explanation and scientific documentation

Repeated samples are drawn from a synthetic population by the chosen method and their estimates compared with the known true value.

Data: A computer simulation with random numbers whose seed you can change; no real data.

Stratification reduces variance when strata are homogeneous within and different between.

Limits: A synthetic population with known properties; in reality you do not know the true value.

Beginner Synthetic data

Central limit theorem simulator

Learning goal: See sample means approach normal from a non-normal population.

Explanation and scientific documentation

Thousands of samples are drawn from a skewed or uniform population and the distribution of their means is drawn.

Data: A computer simulation with random numbers whose seed you can change; no real data.

The standard deviation of the means ≈ σ/√n.

Limits: The approach is slower the more skewed the population is.

Intermediate Synthetic data

Confidence interval simulator

Learning goal: See what 95% means: the share of intervals that cover the true mean.

Explanation and scientific documentation

Many confidence intervals are built from repeated samples and those missing the true mean are coloured.

Data: A computer simulation with random numbers whose seed you can change; no real data.

Observed coverage approaches the stated level as the number of trials grows.

Limits: Assumes sampling from a normal distribution; coverage may differ otherwise.

Intermediate Synthetic data

Hypothesis testing simulator

Learning goal: Run one hypothesis test and read p, effect size and simulated power.

Explanation and scientific documentation

You pick a test (two-sample t, one-sample t, ANOVA, chi-square, two-proportion z), the effect, n and α; a real test is run and then 300 simulations estimate power.

Data: A computer simulation with random numbers whose seed you can change; no real data.

With no effect the rejection rate ≈ α; with a real effect the rejection rate estimates power.

Limits: Data generated from normal distributions; nonparametric tests are not covered.

Advanced Synthetic data

Multiple comparisons and the p-value

Learning goal: See how "significant" results appear by chance when many tests are run.

Explanation and scientific documentation

m tests are run on data with no real effect plus a fraction with a true effect, then Bonferroni and BH corrections are applied.

Data: A computer simulation with random numbers whose seed you can change; no real data.

Without correction the expected false positives ≈ α × the number of null tests.

Limits: Independent tests; dependence between tests changes the details.

Intermediate Synthetic data

Regression explorer

Learning goal: Compare linear and polynomial models and notice overfitting.

Explanation and scientific documentation

A model is trained on a share of the data you set and measured on the rest, with a polynomial degree you choose.

Data: Synthetic data generated in your browser with an editable seed; the relationships are planted on purpose for learning and are not real data.

Training error always falls with degree while test error may rise.

Limits: A descriptive association that does not establish causation.

Related algorithms and methods

t-test

Compares two means, or one mean to a reference, estimating the spread from the sample.

Chi-square

Tests independence of two categorical variables.

ANOVA

Compares means of more than two groups.

Suitable datasets

Practical projects

Assessment questions

Sources and references

  1. Wasserstein, R. L., & Lazar, N. A. (2016). The ASA statement on p-values: context, process, and purpose. The American Statistician, 70(2), 129-133 DOI (bibliographic data entered by the editor, not machine-checked)
  2. James, G., Witten, D., Hastie, T., & Tibshirani, R. (2021). An Introduction to Statistical Learning (2nd ed.). Springer DOI (bibliographic data entered by the editor, not machine-checked)
  3. Hastie, T., Tibshirani, R., & Friedman, J. (2009). The Elements of Statistical Learning (2nd ed.). Springer DOI (bibliographic data entered by the editor, not machine-checked)