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
(Score: 3, Informative) by engblom on Friday July 29 2016, @10:55AM
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) ++ "%")
(Score: 0) by Anonymous Coward on Friday July 29 2016, @12:40PM
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
ⓋⒶ☮✝🕊 Secession is the right of all sentient beings
(Score: 3, Interesting) by gringer on Friday July 29 2016, @01:22PM
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
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