Homework 13 - Monte Carlo Methods

Due: Apr 30 by 11:59pm

Weight: This assignment is worth 4% of your final grade.

Purpose: The purposes of this assignment are:

  • Be able to implement a simple Monte Carlo simulation in R to estimate the probability an even occurring.
  • Be able to conduct a simple Monte Carlo simulation to integrate a function.

Assessment: Each question indicates the % of the assignment grade, summing to 100%. The credit for each question will be assigned as follows:

  • 0% for not attempting a response.
  • 50% for attempting the question but with major errors.
  • 75% for attempting the question but with minor errors.
  • 100% for correctly answering the question.

The reflection portion is always worth 10% and graded for completion.

Rules:

  • Problems marked SOLO may not be worked on with other classmates, though you may consult instructors for help.
  • For problems marked COLLABORATIVE, you may work in groups of up to 3 students who are in this course this semester. You may not split up the work – everyone must work on every problem. And you may not simply copy any code but rather truly work together and submit your own solutions.

Readings

The readings from the last week will serve as a helpful reference as you complete this assignment. You can review them here:

Using AI tools

On this assignment, you are encouraged to use ChatGPT and other AI tools (e.g. Github Copilot). But don’t just blindly copy-paste code. The code provided by these tools is not perfect, and you will likely need to modify it to get the correct solution. If you do use an AI tools, you must include the prompt(s) you used (using a comment with #) to recieve full credit. If you had to change anything to your prompt to get better results, write that down too in your code with a comment. Learn to use tools like ChatGPT as a learning assistant - a tool to help you accomplish the task - rather than just a solutions manual. One version of using it makes you a better and more efficient coder, the other robs you of that.

1) Staying organized [SOLO, 5%]

Download and use this template for your assignment. Inside the “hw13” folder, open and edit the R script called hw13.R and fill out your name, GW netID, and the names of anyone you worked with on this assignment. Coming soon!

2) Monte Carlo Dice [SOLO, 15%]

Using the sample() function, conduct a monte carlo simulation to estimate the probability of rolling a sum of 7 using two 6-sided dice.

3) Monte Carlo Full House [COLLABORATIVE, 15%]

Using the sample() function, conduct a monte carlo simulation to estimate the probability of drawing a “Full House” poker hand from a standard 52-card deck of cards.

4) Monte Carlo Triangles [COLLABORATIVE, 15%]

Using the sample() function, conduct a Monte Carlo simulation to estimate the probability of randomly picking three integer values between 1 and 100 (inclusive, and without replacement) that can be used to form a triangle. As a hint, it would be helpful to first write a simple function called isTriangle(a, b, c) that takes the lengths of three line segments and returns TRUE if the lines can make a triangle and FALSE otherwise. The Triangle Inequality Theorem may come in handy here.

5) Monte Carlo Integration [COLLABORATIVE, 20%]

Use a Monte Carlo simulation to estimate the integral of the function \(y = log(x)\) between \(5 \le x \le 20\) by estimating the area under the curve of the function.

6) Your Own Monte Carlo Simulation [SOLO, 20%]

For the last problem, write your own homework question that requires the student (you) to use a Monte Carlo simulation to compute the probability of an event occurring. Provide both the question and the solution to your question. As with all the other questions, if you use an AI tool like ChatGPT to help you create and / or solve your question, include the prompt you used and comment on any changes you had to make to improve your outcome.

7) Final reflection [SOLO, 10%]

This is your last homework - congrats! 🎉

For this reflection, please reflect on what we have covered in this class, then write about your reflection. I would appreciate it if you could answer the following questions:

  • What was the most impactful thing you gained from this course?
  • What was the most challenging thing you experience in this course?
  • What do you think I can do better in the future?

Write your reflection in a comment (#) in your .R file.

8) Surveys 🙏

This is not for credit, but please, please, please fill out the course surveys. It’s SUPER important that I hear from you so I can learn what is and is not working in this class. Both are anonymous, so be as honest as possible:

  • Official GW Course Evaluation: The official survey GW uses to evaluate how good a job I’m doing.
  • Unofficial survey: This is a survey I put together each year where you can provide me direct, anonymous feedback about things specific to this course.

Submit

Create a zip file of all the files in your R project folder for this assignment, then submit your zip file on the corresponding assignment submission on Blackboard.