Hands-on Data Science
My learning DE

Project4 phases

The Monty Hall Problem

Switch or stay? With a famous guessing game you learn to record an experiment as data, rebuild it in R and play it so often that the data give an answer hardly anyone expects.

Phase 1: Play the game

4 items
  1. Geh aufs Ganze: the game on television Video 5 min
  2. Experiment 1: Three doors in the classroom Experiment 30 min
  3. What should we measure? Demo 10 min
  4. Types of variables Slides 20 min

Phase 2: Games as vectors

5 items
  1. The game with three doors Demo 5 min
  2. Vectors and data frames Slides 45 min
  3. Vectors Lesson 20 min
  4. Numbers, text and logical values Lesson 10 min
  5. Experiment 2: Your games as vectors Experiment 45 min

Phase 3: 100 games as a tibble

2 items
  1. Let's Make a Deal: 100 games with three doors Data set 5 min
  2. Experiment 3: 100 games as a tibble Experiment 60 min

Phase 4: Simulate the game

2 items
  1. Calling functions Lesson 10 min
  2. Experiment 4: The game as a simulation Experiment 60 min
About this project

On a game show there are three doors. Behind one waits a car, behind each of the other two a goat. You choose a door, and the host, who knows where the car is, then opens one of the other two, always one with a goat. Then he asks whether you stay with your door or switch to the other closed one.

Most people are sure that it makes no difference, since two doors are left. Whether that is true you will not find out by thinking in this project, but with data: you play yourselves, record every round, analyse a data set of 100 games and let R repeat the game until the answer no longer depends on chance. Every phase ends with an experiment you carry out as a team.

Along the way you learn what every data analysis needs: how to write down an experiment so that it can be analysed, what such data look like in R as vectors and as a tibble, and how a few lines of code run an experiment as often as you like and turn it into a data set.

What you need

A browser is enough for everything, since the game and R run on the pages of the platform. If you prefer working on your own computer, take Positron and download the data set. For further reading, chapters 5 to 7 of Hands-On Programming with R fit well, on objects, the notation with square brackets and modifying values, and for tibbles and dplyr the first chapters of R for Data Science.

Details
Level
Beginner
Modules
Empirical Research
Code
1663
Updated
3 November 2026
Status
published

    A four-digit code takes you straight to the item.