Maintainer | atloomis@math.arizona.edu |
---|---|
Stability | Experimental |
Safe Haskell | None |
Language | Haskell2010 |
Three type classes for deterministically analyzing
Markov chains with known parameters.
Markov0
is intended to list possible outcomes,
Markov
should allow for more sophisticated analysis.
A more general definition can be found in Markov.Generic
that allows for containers other than lists.
See Markov.Example for examples.
See README for a detailed description.
Synopsis
- class Eq s => Markov0 s where
- transition0 :: s -> [s -> s]
- step0 :: s -> [s]
- chain0 :: Markov0 s => [s] -> [[s]]
- class (Applicative t, Comonad t) => Markov t s where
- transition :: s -> [t (s -> s)]
- step :: t s -> [t s]
- sequential :: [s -> [t (s -> s)]]
- chain :: (Combine (t s), Ord (t s), Markov t s) => [t s] -> [[t s]]
- class Combine a where
- newtype Merge a = Merge a
- newtype Sum a = Sum a
- newtype Product a = Product a
Markov0
Markov
class (Applicative t, Comonad t) => Markov t s where Source #
An implementation of Markov chains.
transition | step | sequential
transition :: s -> [t (s -> s)] Source #
sequential :: [s -> [t (s -> s)]] Source #
Instances
Markov ((,) (Product Rational, Merge String)) Room Source # | |
Markov ((,) (Sum Int, Product Rational)) Extinction Source # | |
Defined in Markov.Example transition :: Extinction -> [((Sum Int, Product Rational), Extinction -> Extinction)] Source # step :: ((Sum Int, Product Rational), Extinction) -> [((Sum Int, Product Rational), Extinction)] Source # sequential :: [Extinction -> [((Sum Int, Product Rational), Extinction -> Extinction)]] Source # | |
Markov ((,) (Product Double)) FillBin Source # | |
Markov ((,) (Product Double)) Tidal Source # | |
Markov ((,) (Product Double)) Urn Source # | |
Markov ((,) (Product Double)) Simple Source # | |
Markov ((,) (Product Double)) FromLists Source # | |
Markov ((,) (Product Int)) Simple Source # | |
Markov ((,) (Sum Int)) Simple Source # | |
chain :: (Combine (t s), Ord (t s), Markov t s) => [t s] -> [[t s]] Source #
Iterated steps, with equal states combined using summarize
operation.
Combine
class Combine a where Source #
Within equivalence classes, combine
should be associative,
commutative, and idempotent (up to equivalence).
I.e. if x == y == z
,
(x `combine` y) `combine` z = x `combine` (y `combine` z)
x `combine` y = y `combine` x
x `combine` x == x
Instances
Combine FillBin Source # | |
Combine Room Source # | |
Combine Tidal Source # | |
Combine Extinction Source # | |
Defined in Markov.Example combine :: Extinction -> Extinction -> Extinction Source # summarize :: NonEmpty Extinction -> Extinction Source # | |
Combine Urn Source # | |
Combine Simple Source # | |
Combine FromLists Source # | |
Num a => Combine (Product a) Source # | |
Combine (Sum a) Source # | |
Combine (Merge a) Source # | |
(Combine a, Combine b) => Combine (a, b) Source # | |
(Combine a, Combine b, Combine c) => Combine (a, b, c) Source # | |
Values from a Monoid
which have the respective
binary operation applied each step,
where different values mean states should not be combined.
E.g., strings with concatenation.
Merge a |
Instances
Enum a => Enum (Merge a) Source # | |
Eq a => Eq (Merge a) Source # | |
Fractional a => Fractional (Merge a) Source # | |
Num a => Num (Merge a) Source # | |
Ord a => Ord (Merge a) Source # | |
Show a => Show (Merge a) Source # | |
Semigroup a => Semigroup (Merge a) Source # | |
Monoid a => Monoid (Merge a) Source # | |
Combine (Merge a) Source # | |
Markov ((,) (Product Rational, Merge String)) Room Source # | |
Values which are added each step, where different values mean states should not be combined. E.g., number of times a red ball is picked from an urn.
Sum a |
Instances
Enum a => Enum (Sum a) Source # | |
Eq a => Eq (Sum a) Source # | |
Fractional a => Fractional (Sum a) Source # | |
Num a => Num (Sum a) Source # | |
Ord a => Ord (Sum a) Source # | |
Show a => Show (Sum a) Source # | |
Num a => Semigroup (Sum a) Source # | |
Num a => Monoid (Sum a) Source # | |
Combine (Sum a) Source # | |
Markov ((,) (Sum Int, Product Rational)) Extinction Source # | |
Defined in Markov.Example transition :: Extinction -> [((Sum Int, Product Rational), Extinction -> Extinction)] Source # step :: ((Sum Int, Product Rational), Extinction) -> [((Sum Int, Product Rational), Extinction)] Source # sequential :: [Extinction -> [((Sum Int, Product Rational), Extinction -> Extinction)]] Source # | |
Markov ((,) (Sum Int)) Simple Source # | |
Values which are multiplied each step, and combined additively for equal states. E.g., probabilities.
Product a |