Monty Hall problem: Difference between revisions

Content added Content deleted
(Emacs Lisp: Improve formatting)
(Added Quackery.)
Line 3,558: Line 3,558:
print("Switch = ",switch)
print("Switch = ",switch)
#Done by Sam Witton 09/04/2014</lang>
#Done by Sam Witton 09/04/2014</lang>

=={{header|Quackery}}==

<lang Quackery> [ $ "bigrat.qky" loadfile ] now!
[ 0 ( number of cars when not changing choice )
0 ( number of cars when changing choice )
rot times
[ 3 random ( door with goat )
3 random ( contestant's choice )
= ( If the two numbers are equal then the contestant
wins a car if they change their mind, and they win
a goat if they don't change their mind. The wins
are reversed if the numbers are not equal. )
if dip 1+ ] ( increment the relevant count )
say "Strategy A is that the contestant changes their mind." cr
say "Strategy B is that the contestant does not their mind." cr
say "Approximate ratio of car wins with strategy A over strategy B: "
swap 100 round
vulgar$ echo$ cr ] is trials ( n --> )</lang>

{{out}}
Running the simulation in the Quackery shell.
<pre>/O> 1000 trials
...
Strategy A is that the contestant changes their mind.
Strategy B is that the contestant does not their mind.
Approximate ratio of car wins with strategy A over strategy B: 15/8

Stack empty.

/O> 1000000 trials
...
Strategy A is that the contestant changes their mind.
Strategy B is that the contestant does not their mind.
Approximate ratio of car wins with strategy A over strategy B: 2/1

Stack empty.
</pre>

From this we can conclude that strategy B is preferable, as goats are the GOAT!


=={{header|R}}==
=={{header|R}}==