Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following variation of the final round of the classic TV game show Let s Make A Deal . There are three doors, and

Consider the following variation of the final round of the classic TV game show Lets
Make A Deal. There are three doors, and behind one of them there is a car, while behind
the other two are goats. You are asked to choose one of the doors, and, without loss of
generality, you choose Door 1. Now, the host Monty Hall opens either Door 2 or Door
3, behind which is a goat. (He never opens up the door with the car behind it.) Monty
now gives you the choice: do you want to stick with Door 1, or switch to the other door.
What should you do? Or does it matter?
In this problem we will create a Monte Carlo simulation of the generalized form of the
Monty Hall problem. Instead of three doors, we will have n doors, where n can be any
number of doors >=3.
1.(20 pts) The Monty Hall problem requires a good deal of generating random numbers.
We will begin by creating and testing two helper functions to generate random numbers
for us.
NOTE: For full credit be sure to use the rand function in the generation of your random
numbers.
(a)(5 pts) Write a Matlab function f = randnum(a,b) which takes as input two integers
a and b, and generates and returns a random integer that is equally likely to take any
value between a and b (inclusive). Save this function in the file randnum.m.
(b)(5 pts) Write a Matlab m-file test_randnum.m that tests the accuracy of your randnum()
function. This program should use randnum() to generate 100,000 random numbers be-
tween 1 and 10. Store each random number in a vector x (it will be of length 100,000 when
the simulation is done). Then display a histogram of the results using the hist(x,1:10)
function.
(c)(5 pts) Write a Matlab function f = randnum_reject(a,b,c) which takes as input
three integers a, b and c, and generates and returns a random integer that is equally likely
to take any value between a and b (inclusive), but will not return the value given by c.
Save this function in the file randnum_reject.m.
(d)(5 pts) Write a Matlab m-file test_randnum_reject.m that tests the accuracy of your
randnum_reject() function. This program should use randnum_reject() to generate
100,000 random numbers between 11 and 20 excluding 15. Store each random number
in a vector x (it will be of length 100,000 when the simulation is done). Then display a
histogram of the results using the hist(x,11:20) function.
1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

More Books

Students also viewed these Databases questions

Question

What committees does the person serve on?

Answered: 1 week ago