Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
25
Task/Monty-Hall-problem/MAXScript/monty-hall-problem-1.max
Normal file
25
Task/Monty-Hall-problem/MAXScript/monty-hall-problem-1.max
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
fn montyHall choice switch =
|
||||
(
|
||||
doors = #(false, false, false)
|
||||
doors[random 1 3] = true
|
||||
chosen = doors[choice]
|
||||
if switch then chosen = not chosen
|
||||
chosen
|
||||
)
|
||||
|
||||
fn iterate iterations switched =
|
||||
(
|
||||
wins = 0
|
||||
for i in 1 to iterations do
|
||||
(
|
||||
if (montyHall (random 1 3) switched) then
|
||||
(
|
||||
wins += 1
|
||||
)
|
||||
)
|
||||
wins * 100 / iterations as float
|
||||
)
|
||||
|
||||
iterations = 10000
|
||||
format ("Stay strategy:%\%\n") (iterate iterations false)
|
||||
format ("Switch strategy:%\%\n") (iterate iterations true)
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
Stay strategy:33.77%
|
||||
Switch strategy:66.84%
|
||||
Loading…
Add table
Add a link
Reference in a new issue