Maths for Machines
0 of 7 lessons done100 questions

Lesson 1 of 7

Data, summaries, and good sampling

A statistic compresses a sample, but no clever formula can rescue data collected from the wrong population.

Core lesson · about 5 minutes · 3 guided parts

Asking only the basketball team about average height gives exact answers about that team, not about the whole school.

Your learning route

Build the idea one piece at a time

  1. Population, sample, parameter, statistic
  2. Spread, visual checks, and study design
  3. Plan a sample before collecting answers
Data, summaries, and good sampling, made visible
sample meana statistic compresses a cloud of observations

Population, sample, parameter, statistic

A parameter describes the whole population; a statistic is calculated from the sample we actually see.

Define the target population and target quantity before collecting data.

The sample mean x̄ estimates population mean μ; sample proportion p̂ estimates population proportion p.

Random sampling helps make selection unrelated to the values being measured.

Begin by writing the population, unit of observation, measurement, and target parameter in words. This prevents a precise calculation from silently answering a different question than the one people care about.

A statistic such as sample mean changes from sample to sample; a population parameter is treated as the fixed unknown target. Statistics are useful because their sampling behavior can be studied under a defined collection process.

Random sampling gives each eligible unit a known selection mechanism and reduces systematic selection. It does not automatically cure nonresponse, bad measurement, missing groups in the frame, or changes between collection and use.

In symbolsx̄=(1/n)Σᵢxᵢ, p̂=successes/n

Worked example

For data 2, 4, 4, 10, find the mean and median.

  1. Add values: 2+4+4+10=20; divide by 4 to get mean 5.
  2. The ordered middle values are 4 and 4.
  3. Their average gives median 4.

Answer: Mean 5; median 4

Spread, visual checks, and study design

Center without spread hides disagreement, and even a perfect calculation cannot repair a biased sample or a confounded comparison.

Range and IQR describe spread; standard deviation weights large deviations more strongly.

Median and IQR resist extreme outliers better than mean and standard deviation.

Always inspect distributions, missingness, units, and impossible values before inference.

In an experiment, random assignment makes treatment groups comparable on average and supports a causal comparison under assumptions. A control group shows what would happen without the treatment; blocking can balance known important groups.

An observational study can reveal association but may contain confounding: a third factor influences both the exposure and outcome. Random sampling helps generalize to a population; random assignment serves the different goal of causal comparison.

A center must be paired with spread and shape. Two classes can have equal mean scores while one is tightly clustered and the other splits between very low and very high scores.

Plot values and inspect units, missingness, duplicates, impossible entries, and outliers before inference. These checks often reveal a data-generation problem that no later formula can repair.

A school evaluating a program defines eligible pupils, randomly samples or records coverage, measures baseline and outcome consistently, and reports median, IQR, mean, and uncertainty. The design matters because conclusions should reflect students rather than quirks of who answered the survey.

In symbolsIQR=Q₃−Q₁, s²=Σ(xᵢ−x̄)²/(n−1)

Worked example

For ordered data 1, 2, 3, 4, 100, which center better describes a typical value: mean or median?

  1. The mean is 110/5=22, pulled upward by 100.
  2. The middle value is median 3.
  3. For a typical observation in this skewed set, median is more representative.

Answer: Median, which is 3

Practical deep dive for this lesson

Plan a sample before collecting answers

A sampling plan is a bridge from the people or objects measured to the population named in the conclusion.

Define the eligible population and construct a frame that covers it. Select units with known probabilities, document unreachable units, and keep the same question and measurement method across selections.

Track response rates and compare responders with known frame information. Weighting can repair known unequal selection probabilities, but it cannot fully reconstruct values for an unobserved group without assumptions.

Report recruitment, exclusions, missingness, and timing beside summary statistics. These details explain why the sample can—or cannot—support a population statement.

In symbolsweighted mean = Σᵢwᵢxᵢ ÷ Σᵢwᵢ, with weights tied to the design

Worked example

A stratified sample represents 600 younger students with sample mean 70 and 400 older students with sample mean 80. Estimate the school-wide mean.

  1. Convert population counts to weights: 0.6 and 0.4.
  2. Weight the younger mean: 0.6×70=42.
  3. Weight the older mean: 0.4×80=32.
  4. Add 42+32=74; an unweighted average of stratum means would target equal-sized strata instead.

Answer: 74

Check your picture

What sample statistic naturally estimates a population proportion p?

Reveal answer

The sample proportion p̂

This lesson versus the whole chapter

Your topic-specific practical example is above.

The final lesson collects five longer chapter-wide workflows for machine learning, LLMs, trading, physics, and everyday decisions.

Formula shelf

Symbols with meaning

Sample meanx̄=Σxᵢ/n

Sample estimate of a population mean.

Unbiased sample variances²=Σ(xᵢ−x̄)²/(n−1)

Spread estimate corrected for estimating the mean.

MSE decompositionMSE=variance+bias²

Total squared estimation error trades variance against bias.

Mean confidence intervalx̄±critical value×SE

A repeated-sampling uncertainty procedure.

Test statisticz=(estimate−null)/SE

Distance from a null value in standard-error units.

Average treatment effectATE=E[Y(1)−Y(0)]

Mean causal contrast between two potential outcomes.

Median absolute deviationMAD=median over i of |xᵢ−median(x)|

Robust measure of typical distance from the median.

Permutation p-value(b+1)/(B+1)

Monte Carlo tail fraction with a finite-simulation correction.

LikelihoodL(θ;x)=p(x|θ)

How strongly parameter θ supports observed data under a model.

Least-squares slopeβ̂₁=Sxy/Sxx

Change in fitted response per unit predictor.

Before moving on

You are ready when you can…

  • Separate populations, samples, parameters, and statistics
  • Distinguish random sampling, randomized assignment, controls, blocking, blinding, and observational confounding
  • Diagnose bias, variance, and sampling uncertainty
  • Use robust summaries without hiding scientifically important extremes
  • Explain bootstrap and permutation assumptions for independent, paired, clustered, or time-dependent data
  • Construct and interpret basic confidence intervals
  • Explain p-values, error types, power, and multiple testing
  • Use likelihood and linear regression without causal overclaiming