probability-0.2.2: Probabilistic Functional Programming
Source code
Contents
Index
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
Instances
Eq
Door
Ord
Door
Show
Door
doors
:: [
Door
]
Source
data
State
Source
Constructors
Doors
prize
::
Door
chosen
::
Door
opened
::
Door
Instances
Eq
State
Ord
State
Show
State
start
::
State
Source
initial configuration of the game status
hide
::
Trans
State
Source
Steps of the game:
hide the prize
choose a door
open a non-open door, not revealing the prize
apply strategy: switch or stay
choose
::
Trans
State
Source
open
::
Trans
State
Source
type
Strategy
=
Trans
State
Source
switch
::
Strategy
Source
stay
::
Strategy
Source
game
::
Strategy
->
Trans
State
Source
Playing the game
data
Outcome
Source
Constructors
Win
Lose
Instances
Eq
Outcome
Ord
Outcome
Show
Outcome
result
::
State
->
Outcome
Source
eval
::
Strategy
->
Dist
Outcome
Source
simEval
::
Int
->
Strategy
->
RDist
Outcome
Source
Alternative modeling
firstChoice
::
Dist
Outcome
Source
switch'
::
Trans
Outcome
Source
Play the game the monadic way
type
StrategyM
=
Door
->
Door
->
Door
Source
stayM
::
StrategyM
Source
switchM
::
StrategyM
Source
evalM
::
StrategyM
->
Dist
Outcome
Source
Produced by
Haddock
version 2.4.2