Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
The Monty Hall Problem with Haskell
Search
Mathias Verraes
May 04, 2016
Technology
2.9k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
The Monty Hall Problem with Haskell
5min lightning talk for the SoCraTes Belgium meetup.
Mathias Verraes
May 04, 2016
More Decks by Mathias Verraes
See All by Mathias Verraes
On Being Explicit
mathiasverraes
0
3.1k
How to Find the Bar
mathiasverraes
1
2.2k
Designed Stickiness
mathiasverraes
1
2.4k
The World's Shortest and Most Chaotic Introduction to Event Storming
mathiasverraes
2
2.9k
Property Based Testing
mathiasverraes
1
2.9k
Towards Modelling Processes
mathiasverraes
3
6k
Modelling Heuristics
mathiasverraes
1
3.2k
Object Reorientation
mathiasverraes
6
3k
Small Controlled Experiments
mathiasverraes
1
4.4k
Other Decks in Technology
See All in Technology
カンファレンスに参加した後の浮遊感とセルフケア
pauli
0
320
全PRの83%が AIレビューだけでマージできるようになった開発組織は その後どうなったか @2026/10
athug
0
130
ハードウェアコンペでもAI駆動開発が進んでいる話
iotengineer22
1
640
無理せず続ける、子育てエンジニアの学び
codmoninc
PRO
0
510
OR学会2026年秋期大会_機械学習と数理最適化の融合による、配合レシピ最適化システム開発事例
brainpadpr
0
110
Deep Data Security 機能解説
oracle4engineer
PRO
2
740
実践! SRE × AI - ABEMA における AIOps -
tetsuya28
7
2.5k
ai_cording_with_k8s_knowledge.pdf
mochizuki875
1
320
おそらく日本で唯一のDevRelインターン生として
husengs7
0
170
OSC2026on_the-world-is-waiting-for-your-voice.pdf
naruoga
0
360
AI駆動開発、viviONの1年 ── うまくいったこと・いかなかったこと
vivion
0
280
分析の民主化を支えるメタデータ整備の実践
kakehashi
PRO
4
1.2k
Featured
See All Featured
Large-scale JavaScript Application Architecture
addyosmani
516
110k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.2k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.4k
BBQ
matthewcrist
90
10k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Producing Creativity
orderedlist
PRO
348
41k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.5k
The Spectacular Lies of Maps
axbom
PRO
1
1.1k
[RailsConf 2023] Rails as a piece of cake
palkan
59
7.1k
Automating Front-end Workflow
addyosmani
1369
210k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
520
Designing for Performance
lara
612
70k
Transcript
The Monty Hall Problem @mathiasverraes
None
None
None
None
None
Don't use thinking when you can use programming — Alan
Turing1 1 Supposedly
data Door = Goat | Car deriving (Eq, Show) type
Game = [Door]
newGame :: MonadRandom m => m Game newGame = shuffleM
[Car, Goat, Goat] newGames :: MonadRandom m => m [Game] newGames = replicateM 100 newGame
(|>) = flip ($) play :: Strategy -> Game ->
Door play strategy game = game |> pickDoor |> revealGoat |> strategy
pickDoor :: Game -> Game pickDoor = id -- Assume
we always pick -- the first door, it -- doesn't matter anyway.
revealGoat :: Game -> Game revealGoat [choice, Goat, x] =
[choice, x] revealGoat [choice, x, Goat] = [choice, x]
type Strategy = Game -> Door stay :: Strategy stay
[firstChoice, alternative] = firstChoice switch :: Strategy switch [firstChoice, alternative] = alternative
do game <- newGame return $ play stay game) --
Goat do game <- newGame return $ play switch game -- Car
playAll :: Strategy -> [Game] -> Int playAll strategy games
= map (play strategy) games |> filter (==Car) |> length
do gs <- newGames return $ playAll stay gs --
32 do gs <- newGames return $ playAll switch gs -- 68
None
module MontyHall where newGame :: MonadRandom m => m Game
newGame = shuffleM [Car, Goat, Goat] import System.Random.Shuffle newGames :: MonadRandom m => m [Game] import Control.Monad.Random.Class newGames = replicateM 100 newGame import Control.Monad pickDoor :: Game -> Game (|>) = flip ($) pickDoor = id data Door = Goat | Car deriving (Eq, Show) revealGoat :: Game -> Game type Game = [Door] revealGoat [choice, Goat, x] = [choice, x] type Strategy = Game -> Door revealGoat [choice, x, Goat] = [choice, x] play :: Strategy -> Game -> Door stay, switch :: Strategy play strategy game = stay [firstChoice, alternative] = firstChoice game switch [firstChoice, alternative] = alternative |> pickDoor |> revealGoat main :: IO() |> strategy main = do (stayCnt, switchCnt) <- do playAll :: Strategy -> [Game] -> Int gs <- newGames playAll strategy games = return (playAll stay gs, playAll switch gs) map (play strategy) games print ("Stay: " ++ show stayCnt) |> filter (==Car) print ("Switch: " ++ show switchCnt) |> length
Full source code: https://gist.github.com/mathiasverraes/ 3a31c912c6efb496566d55ee077dad6f Diagram: Curiouser http://www.curiouser.co.uk/monty/montyhall2.htm Images: AsapScience
http://youtube.com/watch?v=9vRUxbzJZ9Y Inspiration: F# Monty Hall problem by Yan Cui http://theburningmonk.com/2015/09/f-monty-hall-problem/
Thanks :-) @mathiasverraes