Skip to main content
SciNet
  • Home
  • All Courses
  • Calendar
  • Certificates
  • SciNet
    Main Site Documentation my.SciNet
  • CCDB
  • More
Close
Toggle search input
English
English Français
You are currently using guest access
Log in
SciNet
Home All Courses Calendar Certificates SciNet Collapse Expand
Main Site Documentation my.SciNet
CCDB
Expand all Collapse all
  1. MSC1090 - Fall 2026
  2. Assignment 7

Assignment 7

Completion requirements
Opened: Thursday, 29 October 2026, 10:00 AM
Due: Thursday, 5 November 2026, 11:59 PM

Due date: Thursday, November 5th at midnight (Thursday night).


This assignment will explore the Monty Hall Problem, an interesting application of statistics to a game show. The problem is based on one of the games played on Let's Make a Deal, a game show where the host (originally Monty Hall), would make deals with the game-show contestants.

The game in question proceeds as follows. There are 3 doors. One door has a car behind it, the other two doors each have a goat. The contestant is asked to pick one of the doors. Monty Hall then reveals what is behind one of the doors the contestant did not pick: it is a goat. The contestant is then offered a choice: switch her choice of door to the one which is still closed which she did not originally pick, or stay with the door she originally picked. The contestant then wins whatever is behind the door that she ends up picking.

The interesting part of this problem lies in the fact that the probability of guessing the correct door (the door with the car) changes once Monty Hall reveals a door that contains a goat. We will explore this problem in this assignment by repeatedly simulating the game and seeing which option is more successful, or if the choice to switch doors matters at all.


1) Create an R script, named Run.Monty.Hall.R, which:

  • sources the file Monty.Hall.Utilities.R
  • reads an argument from the command line.
    • If the argument is "Keep" the script calls play.monty.hall 100 times without switching the contestant's choice of door. It will then print out a sentence with the result: "When the door is not switched, the fraction of wins is ...".
    • If the command-line argument is "Switch", the script calls play.monty.hall 100 times with switching the contestant's choice of door. It will then print out a similar appropriate sentence.
    • If the command-line argument is neither of the above the script should exit with an appropriate error message.
    • If the number of command-line arguments is not 1 the script should exit with an error message.

Note that you are expected to use coding best practices in all of the work that you submit. This includes, but is not limited to:

  • Plenty of comments in the code, describing what you have done.
  • Sensible variable names.
  • Explicitly returning values, if the function in question is returning a value.
  • Not using the print() function to return values.
  • Proper indentation of code blocks.
  • No use of global variables.
  • Using existing R functionality, when possible.
  • Creating modular code. Using functions.
  • Never copy-and-pasting code!

Assignments will be graded on a 10 point basis. Due date is November 5th 2026 (midnight), with 0.5 point penalty per day for late submission until the cut-off date of November 12th 2026, at 9:00am.

You are currently using guest access (Log in)
Data retention summary


All content on this website is made available under the Creative Commons Attribution 4.0 International licence, with the exception of all videos which are released under the Creative Commons Attribution-NoDerivatives 4.0 International licence.
Powered by Moodle