Copyright | (c) Dominik Schrempf 2020 |
---|---|
License | GPL-3.0-or-later |
Maintainer | dominik.schrempf@gmail.com |
Stability | unstable |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Creation date: Wed May 20 13:42:53 2020.
Synopsis
- data Move a = Move {}
- data MoveSimple a = MoveSimple {}
- data Tuner a
- tuner :: (Double -> MoveSimple a) -> Tuner a
- tune :: Double -> Move a -> Maybe (Move a)
- autotune :: Double -> Move a -> Maybe (Move a)
- data Cycle a
- fromList :: [Move a] -> Cycle a
- autotuneC :: Int -> Acceptance (Move a) -> Cycle a -> Cycle a
- summarizeCycle :: Maybe (Int, Acceptance (Move a)) -> Cycle a -> Text
- newtype Acceptance k = Acceptance {
- fromAcceptance :: Map k [Bool]
- emptyA :: Ord k => [k] -> Acceptance k
- pushA :: (Ord k, Show k) => k -> Bool -> Acceptance k -> Acceptance k
- resetA :: Acceptance k -> Acceptance k
- acceptanceRatios :: Int -> Acceptance k -> Map k Double
Move
A Move
is an instruction about how the Markov chain will traverse the
state space a
. Essentially, it is a probability density conditioned on the
current state.
A Move
may be tuneable in that it contains information about how to enlarge
or shrink the step size to tune the acceptance ratio.
data MoveSimple a Source #
Simple move without tuning information.
In order to calculate the Metropolis-Hastings ratio, we need to know the probability (density) of jumping forth, and the probability (density) of jumping back.
tuner :: (Double -> MoveSimple a) -> Tuner a Source #
Create a Tuner
. The tuning function accepts a tuning parameter, and
returns a corresponding MoveSimple
. The larger the tuning parameter, the
larger the Move
, and vice versa.
autotune :: Double -> Move a -> Maybe (Move a) Source #
For a given acceptance ratio, auto tune the Move
. For now, a Move
is
enlarged when the acceptance ratio is above 0.44, and shrunk otherwise.
Return Nothing
if Move
is not tuneable.
XXX: The desired acceptance ratio 0.44 is optimal for one-dimensional
Move
s; one could also store the affected number of dimensions with the
Move
and tune towards an acceptance ratio accounting for the number of
dimensions.
Cycle
In brief, a Cycle
is a list of moves. The state of the Markov chain will
be logged only after each Cycle
, and the iteration counter will be
increased by one. Moves must have unique names, so that they can be
identified.
Move
s are replicated according to their weights and executed in random
order. That is, they are not executed in the order they appear in the
Cycle
. However, if a Move
has weight w
, it is executed exactly w
times per iteration.
summarizeCycle :: Maybe (Int, Acceptance (Move a)) -> Cycle a -> Text Source #
Acceptance
newtype Acceptance k Source #
For each key k
, store the list of accepted (True) and rejected (False)
proposals. For reasons of efficiency, the lists are stored in reverse order;
latest first.
Acceptance | |
|
Instances
ToJSONKey k => ToJSON (Acceptance k) Source # | |
Defined in Mcmc.Move toJSON :: Acceptance k -> Value # toEncoding :: Acceptance k -> Encoding # toJSONList :: [Acceptance k] -> Value # toEncodingList :: [Acceptance k] -> Encoding # | |
(Ord k, FromJSONKey k) => FromJSON (Acceptance k) Source # | |
Defined in Mcmc.Move parseJSON :: Value -> Parser (Acceptance k) # parseJSONList :: Value -> Parser [Acceptance k] # |
emptyA :: Ord k => [k] -> Acceptance k Source #
In the beginning there was the Word.
Initialize an empty storage of accepted/rejected values.
pushA :: (Ord k, Show k) => k -> Bool -> Acceptance k -> Acceptance k Source #
For key k
, prepend an accepted (True) or rejected (False) proposal.
resetA :: Acceptance k -> Acceptance k Source #
Reset acceptance storage.
acceptanceRatios :: Int -> Acceptance k -> Map k Double Source #
Acceptance ratios averaged over the given number of last iterations. If
less than n
iterations are available, only those are used.