top of page
  • Writer's pictureGunnar Hellmund Laier

Monty Hall Problemet

Updated: Aug 29, 2022


Monty Hall har været diskuteret i mange årtier indenfor anvendt matematik og statistik. Problemet omhandler, hvordan ændrede betingelser stiller en quizdeltager mere gunstigt end under de oprindelige betingelser. I medierne kører historien med jævne mellemrum, og man nævner både et kendt medlem af Mensa med en usædvanlig høj IQ og en matematiker, Erdös i forbindelse med beskrivelsen af problemet og en række praktiske omstændigheder i relation til amerikanske quizshows i sidste århundrede.






Situationen er følgende: En quizdeltager præsenteres med tre valg. Enten åbnes en dør ind til en bil eller en af to døre indtil geder, og quizdeltageren har på den måde mulighed for gevinst eller fiasko. Efter quizdeltageren har foretaget et valg, åbner showmasteren døren indtil en ged, og quizdeltageren udspørges om han ønsker at ændre sit valg, før døren åbnes.

Problemet i matematisk forstand er, hvorvidt det kan betale sig for deltageren at ændre sit valg. Mange har svært ved at forstå, at chancen for gevinst øges væsentligt, selvom det er muligt at beskrive dette både gennem udregning og almindelig logisk virksomhed. Journalistisk er problemet interessant, fordi betingelser for gevinst og tab i offentlige spil er interessante for medierne. Derfor nævnes Monty Hall ofte i perioder med diskussioner om TV spil og Quizshows med forskellige markante udfald eller normændringer.


Den logiske forklaring

Hvis quizdeltageren har valgt døren ind til bilen, kan quizmasteren vælge at åbne en af de to andre døre vilkårligt ind til en ged, før han spørger quizdeltageren, om han vil ændre sit valg. Hvis quizdeltageren derimod har valgt en dør ind til en ged, hvilket han uden foregående viden gør to ud af tre gange, har quizmasteren kun eet valg, når han åbner døren ind til en ged, og i disse tilfælde vil døren, der gemmer bilen, være anden-valget for quizdeltageren, hvis han tager imod tilbuddet. Dermed er sandsynligheden for gevinst 2/3 mod 1/3, hvis han ændrer sit valg. Fortolkningen er i øvrigt i overensstemmelse med frekventistisk fortolkning af sandsynligheder, hvilket er den måde vi tænker sandsynligheder koblet til hænder i kortspil eller udfald ved terningspil eller roulettespil. Hvis du synes forklaringen er lidt uklar, er der hjælp at hente i simulationsberegningen angivet nedenfor.


Den sandsynlighedsteoretiske forklaring: Vi ser på beregningsformlen for betingede sandsynligheder og indsætter udtrykket givet gennem loven om totalsandsynlighed og Bayes’ formel. P(Gevinst|Reduktion) betegner sandsynligheden for at quizdeltageren får en gevinst, hvis han ændrer sit valg, når showmasteren åbner en dør ind til en ged, et sikkert valg, fordi showmasteren har bevidsthed om, hvor bilen befinder sig.


I første linie bruger vi nedenfor definitionen på betinget sandsynlighed, i den næste Bayes’ formel og i den sidste loven om total sandsynlighed.


P(Gevinst|Reduktion) = P(Gevinst, Reduktion)/P(Reduktion) = P(Reduktion|Gevinst)P(Gevinst)/P(Reduktion) = P(Reduktion|Gevinst)P(Gevinst)/ (P(Reduktion,Gevinst)+P(Reduktion,Ikke Gevinst)) = P(Reduktion|Gevinst)P(Gevinst)/ (P(Reduktion|Gevinst)P(Gevinst)+P(Reduktion|Ikke Gevinst)P(Ikke Gevinst)) = P(Reduktion|Gevinst)(1/3)/ (P(Reduktion|Gevinst)(1/3)+P(Reduktion|Ikke Gevinst)P(2/3)) = 1/3


Her er P(Reduktion|…) altid lig 1, og vi genfinder sandsynligheden på 1/3, hvilket er sandsynligheden for at vinde, hvis quizdeltageren ikke ændrer sit valg. Det vil sige, at sandsynligheden for at vinde er 2/3, hvis han ændrer sit valg.


Måske er det lettere, at retfærdiggøre udregningerne ved at se på den komplementere hændelse “andet valg end førstvalgte dør”. P(Ikke Gevinst|Reduktion) betegner sandsynligheden for at tabe ved at fastholde valget fra før quizmasterens afsløring, det er samtidig sandsynligheden for gevinst ved den komplementære hændelse “andet valg end førstvalgte dør”, hvilket reducerer til valget af den sidste låge, efter quizmasters afsløring.


P(Ikke Gevinst|Reduktion) = P(Ikke Gevinst, Reduktion)/P(Reduktion) = P(Reduktion|Ikke Gevinst)P(Ikke Gevinst)/P(Reduktion) = P(Reduktion|Ikke Gevinst)P(Ikke Gevinst)/ (P(Reduktion,Ikke Gevinst)+P(Reduktion,Gevinst)) = P(Reduktion|Ikke Gevinst)P(Ikke Gevinst)/ (P(Reduktion|Ikke Gevinst)P(Ikke Gevinst)+P(Reduktion|Gevinst)P(Gevinst)) = P(Reduktion|Ikke Gevinst)(2/3)/ (P(Reduktion|Ikke Gevinst)(2/3)+P(Reduktion|Gevinst)P(1/3)) = 2/3


Den simulationsbaserede forklaring

Vi antager, at den første dør altid vælges af quizdeltageren, og kombinerer os frem. De to andre tilfælde fjernes fra beregningerne på grund af symmetri, idet vores estimater er frekvensbaserede, ville vi skulle gange med tre samtidig med at vi dividerede med tre.

I simulationskoden nedenfor udvider vi med eksemplet, hvor quizmasteren ikke altid åbner døren til en ged, men vælger døren tilfældigt, og dermed slutter showet, hvis døren fører ind til en bil. På den måde kan vi se, at diskussionen om logikken afhænger af påstande om det gameshow, som vos Savant og Erdös diskuterede.

R

#Number of simulations nsims<-10000 #Monty Hall - simulation #Participant in TV show are given three choices, symbolized with #three doors. Behind two of the doors goats are placed, behind #the third a car is placed. The content behind the chosen door #is for the participant to keep. #Due to symmetry we assume car is placed behind 1st door #The host opens a door to a room with a goat knowingly C<-rep(1,nsims) #Simulate choice of door B<-round(3*(runif(nsims))+0.5) table(B) B2<-B table(B2) #Host choose door with goat, that is not B G<-3*(B==2)+2*(B==3)+(round(2*(runif(nsims))+1.5))*(B==1) table(G) #Chance for participant for getting a car #without changing choice of door print("Without change of choice, P is equal to") sum(B==1)/nsims #Chance for participant for getting a car #changing choice of door (calculation formula)** B<-(B==2)+(B==3)+(B==1)*(5-G) print("With change of choice, P is equal to") sum(B==1)/nsims #Note the calculation formula (**) for the second choice. #If the participant have chosen a door with a goat, there is #only one choice for the host, and the alternative second #choice for the participant is forced to become the door #with the car, thus the probability for winning becomes 2/3. #Host choose a door, that is not B at random #if the door reveals a car the game is over, otherwise the participant #is left with the choice of changing his/hers choice # #The host choose a door at random A<-round(2*(runif(10000))+0.5) table(A) A<-A*(B2==3)+(A+1)*(B2==1)+((A-1)*2+1)*(B2==2) table(A) print("Without change of choice, P is equal to") sum((B2==1))/(sum(A==2)+sum(A==3)) #Chance for participant for getting a car #changing choice of door (calculation formula)** B2<-(B2==2)*(A!=1)+(B2==3)*(A!=1)+(B2==1)*(5-A)*(A!=1) print("With change of choice, P is equal to") sum((B2==1))/(sum(A==2)+sum(A==3))

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

#Number of simulations

nsims<-10000

#Monty Hall - simulation

#Participant in TV show are given three choices, symbolized with

#three doors. Behind two of the doors goats are placed, behind

#the third a car is placed. The content behind the chosen door

#is for the participant to keep.

#Due to symmetry we assume car is placed behind 1st door

#The host opens a door to a room with a goat knowingly

C<-rep(1,nsims)

#Simulate choice of door

B<-round(3*(runif(nsims))+0.5)

table(B)

B2<-B

table(B2)

#Host choose door with goat, that is not B

G<-3*(B==2)+2*(B==3)+(round(2*(runif(nsims))+1.5))*(B==1)

table(G)

#Chance for participant for getting a car

#without changing choice of door

print("Without change of choice, P is equal to")

sum(B==1)/nsims

#Chance for participant for getting a car

#changing choice of door (calculation formula)**

B<-(B==2)+(B==3)+(B==1)*(5-G)

print("With change of choice, P is equal to")

sum(B==1)/nsims

#Note the calculation formula (**) for the second choice.

#If the participant have chosen a door with a goat, there is

#only one choice for the host, and the alternative second

#choice for the participant is forced to become the door

#with the car, thus the probability for winning becomes 2/3.

#Host choose a door, that is not B at random

#if the door reveals a car the game is over, otherwise the participant

#is left with the choice of changing his/hers choice

#

#The host choose a door at random

A<-round(2*(runif(10000))+0.5)

table(A)

A<-A*(B2==3)+(A+1)*(B2==1)+((A-1)*2+1)*(B2==2)

table(A)

print("Without change of choice, P is equal to")

sum((B2==1))/(sum(A==2)+sum(A==3))

#Chance for participant for getting a car

#changing choice of door (calculation formula)**

B2<-(B2==2)*(A!=1)+(B2==3)*(A!=1)+(B2==1)*(5-A)*(A!=1)

print("With change of choice, P is equal to")

sum((B2==1))/(sum(A==2)+sum(A==3))


Vi får følgende output:

R

R version 4.2.0 (2022-04-22 ucrt) -- "Vigorous Calisthenics" Copyright (C) 2022 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > #Number of simulations > nsims<-10000 > #Monty Hall - simulation > #Participant in TV show are given three choices, symbolized with > #three doors. Behind two of the doors goats are placed, behind > #the third a car is placed. The content behind the chosen door > #is for the participant to keep. > #Due to symmetry we assume car is placed behind 1st door > #The host opens a door to a room with a goat knowingly > C<-rep(1,nsims) > #Simulate choice of door > B<-round(3*(runif(nsims))+0.5) > table(B) B 1 2 3 3297 3430 3273 > B2<-B > table(B2) B2 1 2 3 3297 3430 3273 > #Host choose door with goat, that is not B > G<-3*(B==2)+2*(B==3)+(round(2*(runif(nsims))+1.5))*(B==1) > table(G) G 2 3 4983 5017 > #Chance for participant for getting a car > #without changing choice of door > print("Without change of choice, P is equal to") [1] "Without change of choice, P is equal to" > sum(B==1)/nsims [1] 0.3297 > > #Chance for participant for getting a car > #changing choice of door (calculation formula)** > B<-(B==2)+(B==3)+(B==1)*(5-G) > print("With change of choice, P is equal to") [1] "With change of choice, P is equal to" > sum(B==1)/nsims [1] 0.6703 > > #Note the calculation formula (**) for the second choice. > #If the participant have chosen a door with a goat, there is > #only one choice for the host, and the alternative second > #choice for the participant is forced to become the door > #with the car, thus the probability for winning becomes 2/3. > > #Host choose a door, that is not B at random > #if the door reveals a car the game is over, otherwise the participant > #is left with the choice of changing his/hers choice > # > #The host choose a door at random > A<-round(2*(runif(10000))+0.5) > table(A) A 1 2 4966 5034 > A<-A*(B2==3)+(A+1)*(B2==1)+((A-1)*2+1)*(B2==2) > table(A) A 1 2 3 3314 3309 3377 > print("Without change of choice, P is equal to") [1] "Without change of choice, P is equal to" > sum((B2==1))/(sum(A==2)+sum(A==3)) [1] 0.49312 > > #Chance for participant for getting a car > #changing choice of door (calculation formula)** > B2<-(B2==2)*(A!=1)+(B2==3)*(A!=1)+(B2==1)*(5-A)*(A!=1) > print("With change of choice, P is equal to") [1] "With change of choice, P is equal to" > sum((B2==1))/(sum(A==2)+sum(A==3)) [1] 0.50688 > >

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

R version 4.2.0 (2022-04-22 ucrt) -- "Vigorous Calisthenics"

Copyright (C) 2022 The R Foundation for Statistical Computing

Platform: x86_64-w64-mingw32/x64 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.

You are welcome to redistribute it under certain conditions.

Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.

Type 'contributors()' for more information and

'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or

'help.start()' for an HTML browser interface to help.

Type 'q()' to quit R.

> #Number of simulations

> nsims<-10000

> #Monty Hall - simulation

> #Participant in TV show are given three choices, symbolized with

> #three doors. Behind two of the doors goats are placed, behind

> #the third a car is placed. The content behind the chosen door

> #is for the participant to keep.

> #Due to symmetry we assume car is placed behind 1st door

> #The host opens a door to a room with a goat knowingly

> C<-rep(1,nsims)

> #Simulate choice of door

> B<-round(3*(runif(nsims))+0.5)

> table(B)

B

1 2 3

3297 3430 3273

> B2<-B

> table(B2)

B2

1 2 3

3297 3430 3273

> #Host choose door with goat, that is not B

> G<-3*(B==2)+2*(B==3)+(round(2*(runif(nsims))+1.5))*(B==1)

> table(G)

G

2 3

4983 5017

> #Chance for participant for getting a car

> #without changing choice of door

> print("Without change of choice, P is equal to")

[1] "Without change of choice, P is equal to"

> sum(B==1)/nsims

[1] 0.3297

>

> #Chance for participant for getting a car

> #changing choice of door (calculation formula)**

> B<-(B==2)+(B==3)+(B==1)*(5-G)

> print("With change of choice, P is equal to")

[1] "With change of choice, P is equal to"

> sum(B==1)/nsims

[1] 0.6703

>

> #Note the calculation formula (**) for the second choice.

> #If the participant have chosen a door with a goat, there is

> #only one choice for the host, and the alternative second

> #choice for the participant is forced to become the door

> #with the car, thus the probability for winning becomes 2/3.

>

> #Host choose a door, that is not B at random

> #if the door reveals a car the game is over, otherwise the participant

> #is left with the choice of changing his/hers choice

> #

> #The host choose a door at random

> A<-round(2*(runif(10000))+0.5)

> table(A)

A

1 2

4966 5034

> A<-A*(B2==3)+(A+1)*(B2==1)+((A-1)*2+1)*(B2==2)

> table(A)

A

1 2 3

3314 3309 3377

> print("Without change of choice, P is equal to")

[1] "Without change of choice, P is equal to"

> sum((B2==1))/(sum(A==2)+sum(A==3))

[1] 0.49312

>

> #Chance for participant for getting a car

> #changing choice of door (calculation formula)**

> B2<-(B2==2)*(A!=1)+(B2==3)*(A!=1)+(B2==1)*(5-A)*(A!=1)

> print("With change of choice, P is equal to")

[1] "With change of choice, P is equal to"

> sum((B2==1))/(sum(A==2)+sum(A==3))

[1] 0.50688

>

>

11 views0 comments

Comentários


bottom of page