Chapter 2: Probability

This set of labs teaches the essential tools for writing basic simulations to estimate probabilities with the long-run frequency approach, in addition to discussing traditional algebraic approaches for solving probability questions. The programming introduced in these labs (loops and conditionals) will be used in later chapters for demonstrating concepts such as the Central Limit Theorem.
Lab Notes


1. Introduction to Probability

Introduces the basic framework for estimating probability through simulated repetitions of an experiment. The sample() command and syntax for a for loop are introduced in the context of a simple coin flipping experiment, then extended to more complex scenarios.

Handout Template Solutions


2. Conditional Probability

Continues the discussion of control structures by introducing the use of if statements for counting successes and for simulating populations based on conditional probabilities.

Handout Template Solutions


3. Positive Predictive Value (Bayes' Theorem)

Illustrates three common approaches for calculating the positive predictive value of a diagnostic test: contingency tables, tree diagrams, and simulation. The second part of the lab is a conceptual exploration of the relationships between prevalence, sensitivity, specificity, PPV, and NPV.

Handout Template Solutions


4. Probability Extended Practice

Features probability problems that are more extensive than those in the text end-of-chapter exercises, and covers both algebraic and simulation approaches.

Handout Template Solutions