Rank: 3470 based on 9 downloads (last 30 days) and 2 files submitted
photo

Marcus

E-mail

Personal Profile:
Professional Interests:

 

Watch this Author's files

 

Files Posted by Marcus View all
Updated   File Tags Downloads
(last 30 days)
Comments Rating
26 Apr 2010 Screenshot Monty Hall Simulate n rounds of Monty Hall problem with a variable number of doors. Author: Marcus monty hall, game show, monty, hall, probability, statistics 4 4
  • 4.0
4.0 | 2 ratings
19 Jan 2010 Random Hermitian Matrix Generator Generates a random nxn Hermitian matrix. Author: Marcus hermitian, matrix, riemann, zeta, random, generator 5 1
  • 2.0
2.0 | 1 rating
Comments and Ratings by Marcus
Updated File Comments Rating
20 Jan 2010 Monty Hall Simulate n rounds of Monty Hall problem with a variable number of doors. Author: Marcus

Thanks for the helpful review John D'Errico,
I think you misunderstand when I said "the door that Monty opens has no effect on the outcome."; I simply meant that the line of code was irrelevant as the variable 'Monty' was never used again in the function.

I will update the file again soon with some more detailed comments in the code and a better h1 line.
Thanks, Marcus

Comments and Ratings on Marcus' Files View all
Updated File Comment by Comments Rating
24 Jan 2010 Monty Hall Simulate n rounds of Monty Hall problem with a variable number of doors. Author: Marcus D'Errico, John
22 Jan 2010 Monty Hall Simulate n rounds of Monty Hall problem with a variable number of doors. Author: Marcus Petter

John, the program is correct.

20 Jan 2010 Monty Hall Simulate n rounds of Monty Hall problem with a variable number of doors. Author: Marcus Marcus

Thanks for the helpful review John D'Errico,
I think you misunderstand when I said "the door that Monty opens has no effect on the outcome."; I simply meant that the line of code was irrelevant as the variable 'Monty' was never used again in the function.

I will update the file again soon with some more detailed comments in the code and a better h1 line.
Thanks, Marcus

20 Jan 2010 Monty Hall Simulate n rounds of Monty Hall problem with a variable number of doors. Author: Marcus D'Errico, John

This loop does not simulate the Monty Hall problem at all.

    for i = 1:n % Fast sim
        Car = randi(d)-1; % Place Car
        Choose = randi(d)-1; % Choose Door
        %while (Monty==Car || Monty==Choose), Monty=randi(d)-1; end
        % As you can see here, the door that Monty opens has no effect on
        % the outcome.
        if Choose==Car, lose=lose+1; else win=win+1; end % Tally score
        tally=[tally,[win;lose]];
    end

Effectively, it counts the number of times a pair of d sided dice match. This happens 1/d of the time in the long run (1/3 for a three sided die.) But that does not simulate the Monty Hall problem. It merely predicts the number of times that you would have chosen the correct door at random, if both your choice and the door placement are at random, AND you choose to stick with your original choice.

Worse, the statement that the door that Monty opens has no effect on the outcome is simply incorrect, and shows a mis-appreciation of the Monty Hall problem.

So nothing of any value is generated by the code.

There is SOME help provided, but it is mediocre help. I would give the help a rating of about 3.5 stars, if I was rating the help purely on its own. I'll show the top of this function:

function [ ] = montyhall(n,d,detail)
%montyhall Simulates n rounds of the Monty Hall problem and gives win/loss
% d : Number of doors
% detail=0 : Show final win/loss tally and estimated probability
% detail=1 : Shows win/loss chart and estimated probability at end
% detail=2 : Shows results for each round
...

I like that there is an attempt to describe the parameters. I like that there is an H1 line (a descriptive first comment line, with useful keywords in it.) But, suppose that you type

>> help montyhall

in MATLAB? What will you see?

 montyhall Simulates n rounds of the Monty Hall problem and gives win/loss
           d : Number of doors
           detail=0 : Show final win/loss tally and estimated probability
           detail=1 : Shows win/loss chart and estimated probability at end
           detail=2 : Shows results for each round
           
  The Monty Hall problem is a probability puzzle based on the American
  television game show Let's Make a Deal. The name comes from the show's
  host, Monty Hall. The problem is also called the Monty Hall paradox,
  as it is a veridical paradox in that the result appears absurd but is
  demonstrably true.
  http://en.wikipedia.org/wiki/Monty_Hall_problem
  
 
 ------------------------%

As you can see, the result tells you about the parameters, but not necessarily what order they should be in. It does not tell you if the parameters have any default values, or what they are. Are any of these parameters optional?

A good thing is to add a line that shows the actual calling syntax for your function. This lets the user understand how to run your function without needing to edit the code. Forcing them to edit your code just to learn how to use it introduces the possibility of bugs being introduced by accident.

Next, tell the user what they need to know about the parameters. Providing defaults that they never know exist is of no value!

There are no tests to check for erroneous parameters provided.

Next, I like that an outside link was provided to wikipedia. This lets an interested party learn more. I would have been happier had a good explanation of this paradoxical result been provided. While there are internal comments in the code (good!) those comments are confusing and suggests the author seems not yet to truly understand the resolution of this interesting problem.

How about the code itself? This code is better than the first attempt this author submitted. It uses a simple loop to simulate the process. In fact, that simulation could have been done fully vectorized (without loops), although I will not claim that it would have been more understandable code to a novice in that vectorized form.

The biggest issue I have is that the block of code I showed above fails to actually simulate the process under study, and seems not to even understand the issues. As such it forces me to drop my rating of this to about 2.5 stars. Sorry, I've chosen to round it down to 2 stars. (Better than my previous rating of 1 star as I applied to the previous incarnation of this submission, so this is an improvement.)

19 Jan 2010 Monty Hall Simulate n rounds of Monty Hall problem with a variable number of doors. Author: Marcus Shore, Mark

The most intuitive explanation to this alleged paradox for those weak in mathematics and probability (no one reading this of course) is that the host never opens a door hiding a car.

Top Tags Applied by Marcus
game show, generate, generator, hall, hermitian
Files Tagged by Marcus View all
Updated   File Tags Downloads
(last 30 days)
Comments Rating
26 Apr 2010 Screenshot Monty Hall Simulate n rounds of Monty Hall problem with a variable number of doors. Author: Marcus monty hall, game show, monty, hall, probability, statistics 4 4
  • 4.0
4.0 | 2 ratings
19 Jan 2010 Random Hermitian Matrix Generator Generates a random nxn Hermitian matrix. Author: Marcus hermitian, matrix, riemann, zeta, random, generator 5 1
  • 2.0
2.0 | 1 rating

Contact us at files@mathworks.com