notesonly.in

One notebook for every subject — open it anywhere.

Log in

Statistics for Data Science: Complete Beginner's Guide

Statistics is the science of collecting, summarizing, and drawing conclusions from data. For data science it provides the language everything else is built on: means and medians describe a dataset, probability quantifies uncertainty, and hypothesis tests decide whether an observed difference is real or just noise.

It matters because every machine learning model is a statistical machine. Loss functions, confidence intervals, A/B test results, and "the model is 95% confident" all come straight from statistics. Without it you can run the code and still not know whether your results mean anything.

Key Concepts

  • Population vs sample: the population is everything (all customers); a sample is the subset you actually measure.
  • Mean (x̄): the arithmetic average — sensitive to outliers.
  • Median: the middle value when data is sorted — robust to outliers.
  • Variance (σ²) and standard deviation (σ): measures of spread around the mean.
  • Probability distribution: describes how likely each outcome is; the normal (bell-curve) distribution is the most famous.
  • Hypothesis testing: a formal way to decide if an effect is real, using a p-value.
  • Confidence interval: a range that likely contains the true value, for example "between 4.1 and 4.5 with 95% confidence".

Formulas

  • Mean: x̄ = (x₁ + x₂ + … + xₙ) / n. Assumes numeric data; skewed by extreme values.
  • Population variance: σ² = Σ(xᵢ − μ)² / N. Sample variance uses (n − 1) in the denominator (Bessel's correction) to remove bias.
  • Standard deviation: σ = √(σ²). Expressed in the same units as the data, for example minutes or rupees.
  • Z-score: z = (x − μ) / σ. Measures how many standard deviations a value sits from the mean; most meaningful when the distribution is roughly symmetric.
  • Bayes' theorem: P(A|B) = P(B|A)·P(A) / P(B). Updates a belief after seeing evidence; the classic formula behind spam filters.

Worked Example

Delivery times in minutes: 25, 28, 30, 32, 35.

  1. Mean = (25 + 28 + 30 + 32 + 35) / 5 = 150 / 5 = 30.
  2. Deviations from the mean: −5, −2, 0, 2, 5. Squared: 25, 4, 0, 4, 25. Sum = 58.
  3. Sample variance = 58 / (5 − 1) = 14.5.
  4. Standard deviation = √14.5 ≈ 3.81 minutes.
  5. Z-score of a 40-minute delivery = (40 − 30) / 3.81 ≈ 2.63 — unusually slow.

One calculation chain gives the center, the spread, and a way to judge any single delivery as normal or unusual.

Common Misconceptions

  • "The average is always the mean." For skewed data like salaries, the median describes a "typical" person far better.
  • "A p-value of 0.04 proves the effect is real." It means the result would be unlikely if nothing were happening — not proof, and never the probability that the hypothesis is true.
  • "More data always fixes bad statistics." More data shrinks random noise but cannot fix biased sampling or a wrong method.

Real-World Applications

  • A/B testing: websites compare two designs and use hypothesis tests to pick the real winner.
  • Quality control: factories sample products and use statistics to decide whether a whole batch passes.
  • Medicine: clinical trials use statistics to show a drug works better than a placebo.
  • Machine learning: cross-validation and confidence intervals judge whether one model is genuinely better than another.

Statistics turns raw numbers into trustworthy conclusions. Learn the core ideas — center, spread, probability, and testing — and every chart, model, and experiment you meet will make more sense. Data science without statistics is just guessing with a computer.