probability-0.1: Computations with discrete random variables

Collection

Synopsis

Documentation

type Collection a = [a]Source

selectOne :: Eq a => Collection a -> Dist (a, Collection a)Source

select1 :: Eq a => Collection a -> Dist aSource

select2 :: Eq a => Collection a -> Dist (a, a)Source

selectMany :: Eq a => Int -> Collection a -> Dist ([a], Collection a)Source

select :: Eq a => Int -> Collection a -> Dist [a]Source

Example collections

marbles

data Marble Source

Constructors

R
G
B

Instances

bucket :: Collection Marble Source

jar :: Collection Marble Source

pRGB :: Probability Source

pRG :: Probability Source

cards

data Suit Source

Constructors

Instances

data Rank Source

Constructors

Ace

Instances

type Card = (Rank, Suit)Source

plains :: [Rank]Source

faces :: [Rank]Source

isFace :: Card -> Bool Source

isPlain :: Card -> Bool Source

ranks :: [Rank]Source

suits :: [Suit]Source

deck :: Collection Card Source

Example

value :: Card -> Int Source

mini-blackjack: draw 2 cards, and if value is less than 14, continue drawing until value equals or exceeds 14. if values exceeds 21, you lose, otherwise you win.

draw :: ([Card], Collection Card) -> Dist ([Card], Collection Card)Source

drawTo16 :: t -> IO ([Card], Collection Card)Source

win :: ([Card], b) -> Bool Source

chanceWin :: IO (Dist Bool)Source

AltStyle によって変換されたページ (->オリジナル) /