HEG Genève APPLIED STATISTICS · WEEK 12 ← Course
This week
Course
0%
🔧 Week 12 is in preparation. What follows is the plan for the 3-hour session — objectives, the Part 1 sections, the Part 2 exercise outline and the slide outline. Nothing here is counted yet.
Week 12 · Applied Statistics · HEG Genève

Everything from Weeks 1–10, in twelve lines

The exam is by hand; the job is not. This week redoes the whole semester in Python — describe the thirty prices, test the CHF 20 claim, compare the lake and the station, fit the price–rating line, run the chi-square — and gets the same numbers you got with a calculator. Everything runs in Google Colab in the browser, so there is nothing to install and nothing that can go wrong with your laptop. Computer session; bring one anyway.

🏫 In class: 3 h · lesson ~1 h, then exercises ~2 h 📖 Google Colab · pandas · SciPy ▶ The Lecture button shows the slide outline

By the end of Week 12 you will be able to

  • Open a Colab notebook, type a cell, run it — and know where the data went.
  • Put the pizzeria data in a pandas DataFrame and compute mean, median, std, quantiles; draw a histogram and a box plot.
  • Run the semester's tests with scipy.stats — ttest_1samp, ttest_ind, ttest_rel, chi2_contingency, f_oneway — and match each output to the hand calculation from its week.
  • Fit and read a regression with statsmodels, including the slope test and R².
  • Read a Python output without panic: statistic, p-value, degrees of freedom, confidence interval — and keep a notebook that reproduces your project.

Resources

Homework for this week is written with the week itself, on the Week 1–2 pattern: a fresh dataset, hints and worked solutions.
Section 12.1 · The hook

The same numbers

Planned · Hook

Predict which hand calculation Python will disagree with

  • A poll: "which of this semester's results will Python get differently?" (None — but std() will surprise you: pandas divides by n − 1, NumPy by n. The Week 2 trap, one last time.)
  • Reveal: the machine does not know more statistics than you do. It only does the arithmetic faster, and it will happily compute the wrong test.
Status → this section is an outline. When the week is written it becomes an interactive screen on the Week 1–2 pattern: an earned completion, a classify exercise or lab where one is listed, and its own share of the progress bar.
Section 12.2 · Set-up

Colab, cells, a DataFrame

Planned · Set-up

No install · lists, Series, DataFrames, read_csv

  • Step-by-step with screenshots: open Colab, first cell, shift-enter. Why nothing needs installing and where the notebook is saved.
  • The thirty prices as a list → a pandas.Series; the pizzeria table as a DataFrame; pd.read_csv on the course's own CSV.
  • A card on the three imports that carry the whole week: pandas as pd, matplotlib.pyplot as plt, scipy.stats as st.
Status → this section is an outline. When the week is written it becomes an interactive screen on the Week 1–2 pattern: an earned completion, a classify exercise or lab where one is listed, and its own share of the progress bar.
Section 12.3 · Describe

Week 2, in Python

Planned · Describe

describe() · mean · median · std · quantile · hist · boxplot

  • A code block per Week 2 section, each next to the widget it reproduces: s.describe() gives the five-number summary in one line.
  • The n − 1 catch, made visible: s.std() (pandas, ddof=1) vs np.std(s) (ddof=0). Which one is the sample standard deviation, and why the default differs between the two libraries.
  • plt.hist and plt.boxplot — the same pictures, in three lines.
Status → this section is an outline. When the week is written it becomes an interactive screen on the Week 1–2 pattern: an earned completion, a classify exercise or lab where one is listed, and its own share of the progress bar.
Section 12.4 · Infer

Weeks 6–10, in Python

Planned · Infer

ttest_1samp · ttest_ind · ttest_rel · chi2_contingency · f_oneway · OLS

  • One block per test, each checked against the hand result from its week: the CHF 20 claim, lake vs station, before-and-after the menu change, toppings by neighbourhood, four branches.
  • Confidence intervals: st.t.interval — and the same number the Week 6 widget drew.
  • Regression with statsmodels.formula.api.ols: reading summary() line by line — coefficient, standard error, t, p, R².
Status → this section is an outline. When the week is written it becomes an interactive screen on the Week 1–2 pattern: an earned completion, a classify exercise or lab where one is listed, and its own share of the progress bar.
Section 12.5 · Checkpoint

Prove it to yourself

Planned · Quiz

Self-check quiz & where this goes next

  • Eight questions: read four Python outputs and answer the exam-style question each one settles; plus the ddof trap and one "the code ran, the test was wrong" item.
Status → this section is an outline. When the week is written it becomes an interactive screen on the Week 1–2 pattern: an earned completion, a classify exercise or lab where one is listed, and its own share of the progress bar.
Section 12.6 · Workshop

The pizzeria file · instalment twelve

Planned · Exercise

Workbook fields

  • w12_notebook — the Colab link (set to "anyone with the link can view") for the notebook that reproduces your project's numbers.
  • w12_learned — one line on what the notebook told you that the hand calculation did not, and one thing Python made easy that would have been an hour by hand.
Status → this section is an outline. When the week is written it becomes an interactive screen on the Week 1–2 pattern: an earned completion, a classify exercise or lab where one is listed, and its own share of the progress bar.
Part 2 · Exercises

8 exercises, worked together

Planned · ~112 min

The second half of the session

When this week is written, each exercise below becomes a form on this page and a slide in the deck, generated from one array so the two can never disagree — and its solution opens when the instructor reveals it in class. Same engine as Weeks 1–2 (exercises.js).

  • Exercise 1 · First cell  8 min
    open Colab, a list, a Series — and where it saved
  • Exercise 2 · The DataFrame  12 min
    read_csv on the course data, .head(), .describe()
  • Exercise 3 · Describe, reproduced  15 min
    mean, median, std, quantile — matched to your Week 2 answers
  • Exercise 4 · The ddof trap  12 min
    pandas .std() vs numpy .std() — which one is the sample SD
  • Exercise 5 · Two pictures  12 min
    plt.hist and plt.boxplot, three lines each
  • Exercise 6 · Three tests  20 min
    ttest_1samp, ttest_ind, ttest_rel against your hand results
  • Exercise 7 · chi2_contingency and f_oneway  15 min
    the Week 10 tables, reproduced
  • Exercise 8 · Read summary()  18 min
    statsmodels OLS: coefficient, se, t, p, R² — line by line
Status → outline only. Nothing here is interactive or counted yet.