Quiz 2

525 words
3 min read
Python Week 1: the first filter for runtime behavior
Visual companion
Python
Type and operator map

Python Week 1: the first filter for runtime behavior

View
Revision summary

What this note is really saying

Short form

# Statistics I · Week 2 — Categorical data Once variables are categories, analysis is **counting** and **comparing shares** — tables and charts, not means. ## Week map Categories → frequency table → relative frequency → percent → bar chart → pie chart → complements → rounding totals.

Statistics I · Week 2 — Categorical data

Once variables are categories, analysis is counting and comparing shares — tables and charts, not means.

Week map

Categories → frequency table → relative frequency → percent → bar chart → pie chart → complements → rounding totals.

Frequency notation

  • Frequency ff → count in category → 23 students chose tea.
  • Relative frequencyf/nf / n → proportion of whole → 0.23 if n=100n=100.
  • Percent → relative × 100 → 23%.
  • Complement → all categories not A → if A is 30%, complement is 70%.
Constraint: relative frequencies sum to 1 (percents sum to 100%) except rounding drift.
Mini-table: colors Red 40, Blue 35, Green 25, n=100n=100.
  • Rel freq: 0.40, 0.35, 0.25
  • Percents: 40%, 35%, 25%

Charts

Bar chart

  • Categories on axis (nominal or ordinal).
  • Bar height = count or percent.
  • Good for compare across categories.

Pie chart

  • Wedges show part-whole.
  • Works for few categories; weak for many thin slices.
  • Angles proportional to relative frequency.
Trap: pie for unrelated totals not forming one meaningful whole.

Pattern families

Easy — Build frequency table

  • Tally categories from raw list.
  • Compute nn as sum of counts.
  • Relative freq = count/nn.

Medium — Chart choice and read

  • Pick bar vs pie from question goal.
  • Read missing count from percent and nn: count = percent/100 × nn.
  • Compare two categories via difference in counts or percents.

Hard — Rounding and complements

  • Percents sum to 99% or 101% due to rounding — know largest category still identifiable often.
  • Given two category percents, find third when three categories total 100%.
  • Two-way categorical preview: row percent vs overall percent (setup for week 4).

Worked mini-examples

Example 1 — Relative frequency.
120 voters: A 54, B 36, C 30.
n=120n=120. Rel: 0.45, 0.30, 0.25.
Example 2 — Percent to count.
n=250n=250, 16% chose option D → count = 0.16 × 250 = 40.
Example 3 — Complement.
40% walked → 60% did not walk (single binary split).
Example 4 — Missing category.
Three flavors: chocolate 45%, vanilla 30%, strawberry ? → strawberry 25%.
Example 5 — Bar vs pie.
Six transport modes with similar counts → bar chart clearer. Two outcome yes/no → pie or bar both OK.

Traps

  • Confusing frequency with relative frequency.
  • Pie chart with dozens of categories.
  • Percents not summing to 100 — rounding, not always error.
  • Bar chart ordered as if ordinal when nominal — order arbitrary unless by count.
  • Using pie when categories are not parts of one group total.

Diagnostic (try yourself)

  1. Raw: [R,R,B,G,R,B,G,G,R] — build frequency table and nn.
  2. n=80n=80, counts A=32, B=20, C=28. Find relative frequencies and percents.
  3. In a survey, 35% preferred online and 45% preferred hybrid. The only other option is in-person. What percent chose in-person?
  4. n=200n=200, 12.5% chose “other”. How many cases?
  5. When would a bar chart be better than a pie chart for the same categorical data? One sentence.
Document outline

Keep your place and jump directly to a heading.

Table of Contents
System Normal // Awaiting Context

Intelligence Hub

Navigate the knowledge graph to generate context. The Hub adapts dynamically to surface backlinks, related notes, and metadata insights.