Repository navigation
0.2 Choosing Summaries & Visuals
Once you’ve declared a variable’s measurement scale (nominal, ordinal, interval, ratio), the next step is: only use statistic or plot types valid for that scale. Below is a compact guide.
| Scale | Allowed summaries / metrics | Allowed visualizations | Not allowed / misuse to avoid |
|---|---|---|---|
| Nominal | counts, proportions, mode | bar chart, pie (small categories) | mean, standard deviation, histogram (meaningless) |
| Ordinal | median, rank correlations (e.g. Spearman) | bar chart (ordered), boxplot of ranks | arithmetic mean (unless evenly spaced), variance with caution |
| Interval | mean, standard deviation, differences | histogram, density plot, boxplot | true “zero‑based” ratios (only differences meaningful) |
| Ratio | all interval metrics + meaningful ratios | same as interval + log scales if needed | none in the standard sense (all metrics valid) |
Procedure:
- For each variable, annotate its scale (in data dictionary or schema).
- When choosing a summary or statistic, refer back to this table.
- For visualizations, match type to permissible plots above.
- If you ever see code taking a mean of a nominal code (e.g. 0/1 categories), flag for correction.
# Example: binary treatment (nominal) → use proportion & bar, not mean code:
import pandas as pd
df = pd.DataFrame({"group": ["A","B","A","B","A","A","B"], "outcome": [0,1,0,1,0,1,1]})
counts = df.groupby("group")["outcome"].value_counts(normalize=True).unstack(fill_value=0)
print(counts)
counts.plot(kind="bar", stacked=True)You can also encode nominal codes as pd.Categorical (unordered) so that accidental numeric ops error out.
Page: 0.1 Measurement Scales & Variable Types
Section: After the definitions / examples of nominal, ordinal, interval, ratio — insert a new subheading “0.2 From Scales → Choosing Summaries & Visuals (Statistical hygiene)”
-
Variable “color of car” (red/blue/green) → what summary metric and plot do you choose?
Answer: counts / proportions; bar chart (categorical); not mean or histogram. -
Variable “customer satisfaction” rated 1–5, with ordinal scale → is taking the mean valid?
Answer: only if you assume equal spacing; safer to use median, rank correlation, or treat it as ordinal in box/rank plots. -
You see code
df["gender_code"].mean()wheregender_codeis encoded 0 = male, 1 = female. What’s wrong and what to replace?
Answer: Taking a mean of nominal binary is meaningless — instead compute proportiondf["gender_code"].mean()is okay but only if clearly documented and interpreted as proportion; better: treat as nominal and show counts/proportions with bar chart.
Next pages / sections to build:
- 1. Probability → as earlier patch suggested: events, conditional, Bayes, total probability.
- 2. Descriptive Statistics → deeper: variance, covariance, quantiles; tie to scale table above.
- 3. Visualization → mapping plot types to data shapes and objectives (e.g. scatter, line, faceting).
- 4. Data Cleaning / Type Enforcement → enforcing categorical dtype, safe coercion, missingness policies.
- 5. Inference / Hypothesis Testing → building on probability + descriptive foundations.
That single inserted “scale → summary/plot” guide will reduce many future misapplications, and anchor all downstream choices to sound foundations.
- Q1: A variable “browser type” (Chrome, Firefox, Safari) — what summary metric and plot should you use?
A1: counts or proportions; bar chart. (Not mean or histogram of codes.) - Q2: A satisfaction rating 1‑5 (ordinal) — is it always valid to compute the mean?
A2: No — only if spacing is truly equal and you treat it as interval; safer: median or percentiles. - Q3: A variable “time since signup (in days)” (ratio) — what summaries/plots are valid?
A3: mean, sd, ratios (e.g., twice as long), histogram, density plot; log scale if heavy tail.
Legend:
- 🔰 Start here
- 🏵️ Important Insight
- ⚙️ Technical and applications
- 💻 Some Code
- ⚜️ Advanced Topics
- 00.1 What Is Data?
-
00.2 Three Models of Reality (planned)
- 00.2.1 The Linguistic
- 00.2.2 The Symbolic
- 00.3.3 The Mathematical
- 00.3 Maps and Reality
- 00.4 Aside: Hossack, data as structure
- 00.5 Aside: Chomsky, data as evidence
- 01.1 🔰 Sets and Logic (planned)
- 01.2 Sample Space
- 01.3 Randomness and Pattern
- 01.4 Outcomes and Events
- 01.5 Finite and Infinite Sample Spaces
- 02.1 🔰 Functions (planned)
- 02.2 Types Are Alphabets
- 02.3 Random Variables: X : Ω → 𝒳 (planned)
- 02.4 Measurement Scales
- 02.5 Numerics
- 03.1 🔰 Fractions and Proportions (planned)
- 03.2 Randomness vs Uncertainty
- 03.3 Probability: Events, Conditioning, Bayes
- 03.4 Bayes' Theorem, Step by Step
- 03.5 Expected Value and Variance (planned)
- 03.6 Bernoulli (ES)
- 03.7 Discrete Uniform (ES)
- 03.8 🧗 Kolmogorov: Ω, 𝒜, ℙ
- 04.1 🔰 Powers and Logarithms (planned)
- 04.2 Rarity
- 04.3 Information Theory (Shannon)
- 04.4 Entropy: Three Views
- 05.1 🔰 Sums and Averages (planned)
- 05.2 Data, Measured
- 05.3 Sampling (ES)
- 05.4 Population and Sample (ES)
- 05.5 Types of Sampling (ES)
- 05.6 Choosing Summaries & Visuals
- 05.7 Visualization
- 05.8 Plots
- 06.1 What Is Statistics?
- 06.2 🔰 Curves and Area (planned)
- 06.3 Statistical Thinking
- 06.4 Variation
- 06.5 Uncertainty
- 06.6 Parameters vs Estimators (ES)
- 06.7 Distributions
- 06.8 Statistical Modeling
- 06.9 Statistical Methods
- 07.1 Data Storage: Databases (stub)
- 07.2 ER Diagrams
- 07.3 Chen Diagrams
- 07.4 SQL (planned)
- 07.5 Formal Languages and Regular Expressions (planned)
- 07.6 Reproducibility (planned)
08 · μ(x) — Fuzzy - When data is flexible
- 08.1 Fuzzy Logic (planned)
- 08.2 Fuzzy Numbers (planned)
- 08.3 Possibility vs Probability (planned)
09 · x(t) — Signals and systems - Where patterns live
- 09.1 Signals (stub)
- 09.2 Sampling and Aliasing (planned)
- 09.3 Convolution (planned)
- 09.4 Frequency (planned)
- 10.1 🔰 Vectors and Matrices (planned)
- 10.2 Mathematical Modelling (planned)
- 11.1 🔰 Derivatives (planned)
- 11.2 Convex Optimisation (planned)
- 12.1 Supervised Learning (planned)
- 12.2 Data in Language Models
- 13.1 Cause and Effect (planned)
- 13.2 Capstone Guide (planned)