SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Monty Hall Paradox


Monty Hall Paradox

Author
Message
Sean Smith (SSC)
Sean Smith (SSC)
UDP Broadcaster
UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)

Group: General Forum Members
Points: 1494 Visits: 1012
Comments posted to this topic are about the item Monty Hall Paradox
TPalmeri
TPalmeri
Forum Newbie
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: General Forum Members
Points: 5 Visits: 17
(removed)
Jason Whitney
Jason Whitney
SSC-Enthusiastic
SSC-Enthusiastic (120 reputation)SSC-Enthusiastic (120 reputation)SSC-Enthusiastic (120 reputation)SSC-Enthusiastic (120 reputation)SSC-Enthusiastic (120 reputation)SSC-Enthusiastic (120 reputation)SSC-Enthusiastic (120 reputation)SSC-Enthusiastic (120 reputation)

Group: General Forum Members
Points: 120 Visits: 553
That is an interesting puzzle. Here is another solution using a CTE instead of a loop.

-- Setup
set nocount on

-- Create a table to store the results.
create table Doors
( ID int
, ChosenDoor int
, WinningDoor int
, WinLose as case when ChosenDoor = WinningDoor then 0 else 1 end -- Win = 1, Lose = 0
);

-- Use a CTE to generate 10,000 "contestants" and their chosen/winning doors.
-- If the chosen door equals the winning door the contestant will switch when given the
-- option and lose. Otherwise they will switch to the winning door and win.
with Digits(i)
as (select i
from (select 1 union select 2 union select 3 union select 4 union select 5 union
select 6 union select 7 union select 8 union select 9 union select 0) AS X(i))
insert into Doors(ID, ChosenDoor, WinningDoor)
select (D3.i * 1000 + D2.i * 100 + D1.i * 10 + D0.i) AS seq
, abs(cast(cast(newid() as varbinary) as int)) % 3 + 1 ChosenDoor
, abs(cast(cast(newid() as varbinary) as int)) % 3 + 1 WinningDoor
from Digits as D0, Digits as D1, Digits as D2, Digits as D3

-- Select the total number of winners (1) and losers (0).
select WinLose
, count(*) Total
from Doors
group by WinLose

-- Clean-up
drop table Doors
set nocount off


Sean Smith (SSC)
Sean Smith (SSC)
UDP Broadcaster
UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)

Group: General Forum Members
Points: 1494 Visits: 1012
Very cool alternative. Thanks for sharing! Smile
brosspaxedi
brosspaxedi
Old Hand
Old Hand (321 reputation)Old Hand (321 reputation)Old Hand (321 reputation)Old Hand (321 reputation)Old Hand (321 reputation)Old Hand (321 reputation)Old Hand (321 reputation)Old Hand (321 reputation)

Group: General Forum Members
Points: 321 Visits: 261
I think this is bogus. The reason that I think it is bogus is that on the second bet you are excluding the door you picked from your first bet ONLY if it is not the right door. So you are adding new information.

*******************
What I lack in youth, I make up for in immaturity!
Sean Smith (SSC)
Sean Smith (SSC)
UDP Broadcaster
UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)

Group: General Forum Members
Points: 1494 Visits: 1012
brosspaxedi (11/10/2014)
I think this is bogus. The reason that I think it is bogus is that on the second bet you are excluding the door you picked from your second bet ONLY if it is not the right door. So you are adding new information.


Thanks for sharing you're wonderful insight.
Sean Smith (SSC)
Sean Smith (SSC)
UDP Broadcaster
UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)

Group: General Forum Members
Points: 1494 Visits: 1012
I am surprised anyone even found this old post. LOL.
Iwas Bornready
Iwas Bornready
SSC-Insane
SSC-Insane (22K reputation)SSC-Insane (22K reputation)SSC-Insane (22K reputation)SSC-Insane (22K reputation)SSC-Insane (22K reputation)SSC-Insane (22K reputation)SSC-Insane (22K reputation)SSC-Insane (22K reputation)

Group: General Forum Members
Points: 22874 Visits: 885
Interesting script.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search