Project 7: Counting, Combinatorics, and Modeling Studio

A self-contained deep-dive from the canonical Math from Foundations to Machine Learning curriculum.

  • Difficulty: Advanced
  • Time: 14-28 hours
  • Language: Python (alternatives: R, Julia, JavaScript)
  • Prerequisites: Projects 2 and 6
  • Source: HS P20

What You Will Build

Build a scenario-driven modeling studio that turns a small real-world question into explicit variables, assumptions, units, counting rules, uncertainty ranges, and a decision-ready report. Support sum/product rules, factorials, permutations, combinations, and probability derived from favorable versus possible outcomes. Scenarios can be loaded from JSON/YAML or CLI parameters—for example staffing schedules, password spaces, tournament outcomes, inventory bundles, or sampling plans. The engine should reject unit-inconsistent equations, compare alternative assumptions, and produce sensitivity tables showing which inputs most affect the result.

Real World Outcome

Given a scenario for selecting a five-person committee with role constraints, the tool prints the valid counting formula, evaluates it, verifies small cases by enumeration, and explains whether order matters. Given an operational estimate, it checks dimensions, runs low/base/high assumptions, ranks influential inputs, and exports a Markdown report containing result, uncertainty, limitations, and a warning when independence or uniformity was assumed without evidence.

Core Question

How do you translate an ambiguous situation into a mathematical model whose assumptions, units, and counting choices can be inspected and challenged?

Concepts You Must Understand First

  1. Sum and product rules: mutually exclusive alternatives add; sequential independent choices multiply.
  2. Permutations versus combinations: decide whether order matters and whether repetition is allowed. See Graham et al., Concrete Mathematics, counting chapters.
  3. Sample spaces and probability: specify what counts as an outcome before declaring outcomes equally likely.
  4. Dimensional analysis: valid addition requires compatible units; multiplication/division creates derived units.
  5. Sensitivity analysis: vary one or several assumptions to expose fragile conclusions.

Build Milestones

  1. Define a scenario schema with quantities, units, assumptions, constraints, and requested outputs.
  2. Implement counting primitives and a trace that explains why each rule applies.
  3. Add brute-force enumeration for small instances as a verification oracle.
  4. Build a unit checker and low/base/high plus one-at-a-time sensitivity analysis.
  5. Export a report that separates facts, assumptions, computed results, and limitations.

Hints in Layers

  1. Ask four questions before choosing a formula: order, repetition, distinct objects, and constraints.
  2. Represent units symbolically as exponent maps so km / hour survives calculations.
  3. Keep the pure model function separate from scenario iteration; then sensitivity analysis is repeated evaluation, not duplicated logic.

Common Pitfalls and Debugging

  • Symptom: committee counts are too large by a factorial factor. Cause: permutations were used where order is irrelevant. Fix: verify a tiny case by listing outcomes.
  • Symptom: an equation adds hours to people. Cause: units were stripped before computation. Fix: carry unit metadata through every operation.
  • Symptom: sensitivity results never change. Cause: scenarios mutated display values but not model inputs. Fix: log the actual parameter map passed to each run.

Definition of Done

  • Counting primitives handle order/repetition cases and explain their selection.
  • Small cases agree with explicit enumeration.
  • Scenario inputs retain units and inconsistent operations fail clearly.
  • Low/base/high and sensitivity runs are reproducible.
  • Reports distinguish observations, assumptions, results, uncertainty, and limitations.
  • At least three meaningfully different scenarios exercise the engine.

Previous: Project 6 · Complete learning path · Next: Project 8