I'm writing a quick a simulation for The Monty Hall Problem but it comes up with winning a car 75% of the time, even with 20k simulations. It does that every time, but I can't understand why. It should win a car 66% of the time. Any ideas? Here's my procedure for a single simulation:
CheersCode:Private Function Simulate() As Boolean 'true means a car was won; false means a goat was won Dim Door(2) As Boolean Dim doornum As SByte Dim choice As SByte = 0 'initially choose the first door every time Randomize() doornum = Math.Round(Rnd() * 2) 'generate a random number between 0 and 2 Door(doornum) = True 'set a random door to have a car behind it If Door(1) = False Then 'if the second (zero-based) door is opened, choice = 2 'choose the third ElseIf Door(2) = False Then 'if the third door is opened, choice = 1 'choose the second End If 'change choice to one of the other doors If Door(choice) Then 'if the new choice has a car, Return True Else 'if the new choice doesn't have a car Return False End If End Function![]()


Reply With Quote
