probability-0.2.2.1: Probabilistic Functional ProgrammingSource codeContentsIndex
Numeric.Probability.Example.MontyHall
Contents
Playing the game
Alternative modeling
Play the game the monadic way
Synopsis
data Door
= A
| B
| C
doors :: [Door]
data State = Doors {
prize :: Door
chosen :: Door
opened :: Door
}
start :: State
hide :: Trans State
choose :: Trans State
open :: Trans State
type Strategy = Trans State
switch :: Strategy
stay :: Strategy
game :: Strategy -> Trans State
data Outcome
= Win
| Lose
result :: State -> Outcome
eval :: Strategy -> Dist Outcome
simEval :: Int -> Strategy -> RDist Outcome
firstChoice :: Dist Outcome
switch' :: Trans Outcome
type StrategyM = Door -> Door -> Door
stayM :: StrategyM
switchM :: StrategyM
evalM :: StrategyM -> Dist Outcome
Documentation
data Door Source
Constructors
A
B
C
show/hide Instances
doors :: [Door]Source
data State Source
Constructors
Doors
prize :: Door
chosen :: Door
opened :: Door
show/hide Instances
start :: StateSource
initial configuration of the game status
hide :: Trans StateSource

Steps of the game:

  1. hide the prize
  2. choose a door
  3. open a non-open door, not revealing the prize
  4. apply strategy: switch or stay
choose :: Trans StateSource
open :: Trans StateSource
type Strategy = Trans StateSource
switch :: StrategySource
stay :: StrategySource
game :: Strategy -> Trans StateSource
Playing the game
data Outcome Source
Constructors
Win
Lose
show/hide Instances
result :: State -> OutcomeSource
eval :: Strategy -> Dist OutcomeSource
simEval :: Int -> Strategy -> RDist OutcomeSource
Alternative modeling
firstChoice :: Dist OutcomeSource
switch' :: Trans OutcomeSource
Play the game the monadic way
type StrategyM = Door -> Door -> DoorSource
stayM :: StrategyMSource
switchM :: StrategyMSource
evalM :: StrategyM -> Dist OutcomeSource
Produced by Haddock version 2.4.2