Stories
Slash Boxes
Comments

SoylentNews is people

posted by janrinok on Friday July 29 2016, @10:27AM   Printer-friendly
from the something-to-think-about dept.

Suppose you're on a game show, and you're given the choice of three doors: Behind one door is a car; behind the others, goats. You pick a door, say No. 1, and the host, who knows what's behind the doors, opens another door, say No. 3, which has a goat. He then says to you, "Do you want to pick door No. 2?" Is it to your advantage to switch your choice?

Do any of you have any noteworthy experiences where knowledge of math helped you in an unusual way?

https://en.wikipedia.org/wiki/Monty_Hall_problem


Original Submission

 
This discussion has been archived. No new comments can be posted.
Display Options Threshold/Breakthrough Mark All as Read Mark All as Unread
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
  • (Score: 3, Informative) by engblom on Friday July 29 2016, @10:55AM

    by engblom (556) on Friday July 29 2016, @10:55AM (#381481)
    Here is a simulation of the game written in Haskell. Put it into a file called monte.hs and then type 'runghc monte.hs':

    import System.Random

    attempts = 100000

    play :: Int -> Int -> Int -> IO (Int, Int)
    play 0 stayWin swapWin = return (stayWin, swapWin)
    play attempt stayWin swapWin = do
        car <- randomRIO (0, 2) :: IO Int
        choice <- randomRIO (0, 2)
        if car == choice
           then play (attempt-1) (stayWin+1) swapWin
           else play (attempt-1) stayWin (swapWin+1)

    main :: IO()
    main = do
        (stayWin, swapWin) <- play attempts 0 0
        putStrLn ("Stay winning percentage: " ++ show ( (fromIntegral stayWin)/(fromIntegral attempts)*100) ++ "%")
        putStrLn ("Swap winning percentage: " ++ show ( (fromIntegral swapWin)/(fromIntegral attempts)*100) ++ "%")
    Starting Score:    1  point
    Moderation   +1  
       Informative=1, Total=1
    Extra 'Informative' Modifier   0  
    Karma-Bonus Modifier   +1  

    Total Score:   3  
  • (Score: 0) by Anonymous Coward on Friday July 29 2016, @12:40PM

    by Anonymous Coward on Friday July 29 2016, @12:40PM (#381501)

    I always wanted to learn Haskell.

    Now, however, I just understand why a Haskell user would think "Learn You a Haskell for Great Good" is somehow an appropriate title, or sentence in English.

  • (Score: 4, Interesting) by jdavidb on Friday July 29 2016, @12:59PM

    by jdavidb (5690) on Friday July 29 2016, @12:59PM (#381507) Homepage Journal
    This takes me back. In the 1980s somehow my dad and I became enamored of this problem. We spent a long time trying to work it out and Dad even called one of his old college professors for some assistance in understanding it. Then a buddy of dad's from work gave us a program in Applesoft Basic that ran and counted many trials of the problem to demonstrate the true odds, which I proceeded to painstakingly key in to my Apple II Gs. I don't think I believed anything we heard about the problem until I saw the simulation run with my own eyes. That was also probably one of my earliest experiences seeing how programs could be used to model a situation.
    --
    ⓋⒶ☮✝🕊 Secession is the right of all sentient beings
  • (Score: 3, Interesting) by gringer on Friday July 29 2016, @01:22PM

    by gringer (962) on Friday July 29 2016, @01:22PM (#381518)

    non-recursive R version, for those who had difficulty understanding the Haskell version:

    #!/usr/bin/Rscript
    system.time({
            attempts <- 10000000;
            car <- sample(1:3, attempts, replace=TRUE);
            choice <- sample(1:3, attempts, replace=TRUE);
            stayWin <- sum(car==choice);
            swapWin <- sum(car!=choice);
            cat(sprintf("Stay winning percentage: %0.2f%%\n",stayWin/attempts * 100));
            cat(sprintf("Swap winning percentage: %0.2f%%\n",swapWin/attempts * 100));
    });

    Output:

    Stay winning percentage: 33.34%
    Swap winning percentage: 66.66%
                  User System verstrichen
                0.560 0.092 0.653

    --
    Ask me about Sequencing DNA in front of Linus Torvalds [youtube.com]
    • (Score: 2) by JoeMerchant on Friday July 29 2016, @03:01PM

      by JoeMerchant (3937) on Friday July 29 2016, @03:01PM (#381554)

      This statement makes it clear for me:

      swapWin - sum(car!=choice);

      If you pick the car the first time, then swapping will cause you to lose, but if you pick a goat the first time, then swapping will cause you to win.

      --
      Україна досі не є частиною Росії Слава Україні🌻 https://news.stanford.edu/2023/02/17/will-russia-ukraine-war-end