úÎ!'åA³      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRST U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s tuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²Links of Markov chains(c) Dominik Schrempf 2020GPL-3.0-or-laterdominik.schrempf@gmail.comunstableportableNone mcmcAn , or link of the Markov chain. For reasons of computational efficiency, each state is associated with the corresponding prior and likelihood.mcmc%The current state in the state space a.mcmcThe current prior.mcmcThe current likelihood.Monitor logarithmic values(c) Dominik Schrempf, 2020GPL-3.0-or-laterdominik.schrempf@gmail.comunstableportableSafe‹ mcmcPrint a log value.  Monitor parameters(c) Dominik Schrempf, 2020GPL-3.0-or-laterdominik.schrempf@gmail.comunstableportableSafeSXØmcmc)Instruction about a parameter to monitor.mcmcName of parameter.mcmc>Instruction about how to extract the parameter from the state.mcmcGConvert a parameter monitor from one data type to another using a lens.LFor example, to monitor a real float value being the first entry of a tuple: mon = _1 @@ monitorRealFloat mcmc$Monitor integral parameters such as ³.mcmc&Monitor real float parameters such as ´- with eight decimal places (half precision).mcmc&Monitor real float parameters such as ´ with full precision.mcmc&Monitor real float parameters such as ´4 with scientific notation and eight decimal places.mcmcName of monitor.mcmcName of monitor.mcmcName of monitor.mcmcName of monitor.  Monitor parameters(c) Dominik Schrempf, 2020GPL-3.0-or-laterdominik.schrempf@gmail.comunstableportableSafeSX7Œ mcmcëInstruction about a parameter to monitor via batch means. Usually, the monitored parameter is average over the batch size. However, arbitrary functions performing more complicated analyses on the states in the batch can be provided.‚XXX: Batch monitors are slow at the moment because the monitored parameter has to be extracted from the state for each iteration.mcmc"Name of batch monitored parameter.mcmc?Instruction about how to extract the batch mean from the trace.mcmcNConvert a batch parameter monitor from one data type to another using a lens.RFor example, to batch monitor a real float value being the first entry of a tuple: &mon = _1 @# monitorBatchMeanRealFloat mcmc*Batch monitor integral parameters such as ³=. Print the mean with eight decimal places (half precision).mcmc*Batch monitor integral parameters such as ³&. Print the mean with full precision.mcmc,Batch monitor real float parameters such as ´- with eight decimal places (half precision).mcmc,Batch monitor real float parameters such as ´ with full precision. mcmc,Batch monitor real float parameters such as ´4 with scientific notation and eight decimal places.!mcmc6Batch monitor parameters with custom lens and builder.mcmcName of monitor.mcmcName of monitor.mcmcName of monitor.mcmcName of monitor. mcmcName of monitor.!mcmcName of monitor.mcmc%Function to calculate the batch mean.mcmcCustom builder.  !  !Print time related values(c) Dominik Schrempf, 2020GPL-3.0-or-laterdominik.schrempf@gmail.comunstableportableSafe<Ù"mcmc;Adapted from System.ProgressBar.renderDuration of package  ?https://hackage.haskell.org/package/terminal-progress-bar-0.4.1terminal-progressbar-0.4.1.#mcmcRender duration in seconds."#"#Shuffle a list(c) Dominik Schrempf 2020GPL-3.0-or-laterdominik.schrempf@gmail.comunstableportableNoneA®$mcmcShuffle a list.%mcmcShuffle a list n times.&mcmcgrabble xs m n is O(m*n'), where n' = min n (length xs) . Choose n' elements from xs , without replacement, and that m times.$%&$%&Proposals and cycles(c) Dominik Schrempf 2020GPL-3.0-or-laterdominik.schrempf@gmail.comunstableportableNoneSX~¦'mcmc For each key k6, store the number of accepted and rejected proposals.)mcmc In brief, a )V is a list of proposals. The state of the Markov chain will be logged only after all 6 s in the )b have been completed, and the iteration counter will be increased by one. The order in which the 6 s are executed is specified by +. The default is ,. Proposals must have unique names!, so that they can be identified.+mcmcDefine the order in which 6s are executed in a ). The total number of 6s per ) may differ between +s (e.g., compare , and .).,mcmc Shuffle the 6 s in the ). The 6Ps are replicated according to their weights and executed in random order. If a 6 has weight w, it is executed exactly w times per iteration.-mcmcThe 6>s are executed sequentially, in the order they appear in the ). 6s with weight w>1 are repeated immediately w2 times (and not appended to the end of the list)..mcmc Similar to ,5. However, a reversed copy of the list of shuffled 6`s is appended such that the resulting Markov chain is reversible. Note: the total number of 6.s executed per cycle is twice the number of ,./mcmc Similar to -@. However, a reversed copy of the list of sequentially ordered 6Bs is appended such that the resulting Markov chain is reversible.0mcmcTune the acceptance ratio of a 6; see >, or C.3mcmc+Simple proposal without tuning information.jInstruction about randomly moving from the current state to a new state, given some source of randomness.×In order to calculate the Metropolis-Hastings ratio, we need to know the ratio of the backward to forward kernels (i.e., the probability masses or probability densities). For unbiased proposals, this ratio is 1.0.6mcmcA 6M is an instruction about how the Markov chain will traverse the state space ar. Essentially, it is a probability mass or probability density conditioned on the current state (i.e., a kernel).A 6| may be tuneable in that it contains information about how to enlarge or shrink the step size to tune the acceptance ratio.8mcmc7Name (no proposals with the same name are allowed in a )).9mcmc"The weight determines how often a 60 is executed per iteration of the Markov chain.:mcmc+Simple proposal without tuning information.;mcmcTuning is disabled if set to µ.<mcmc>Convert a proposal from one data type to another using a lens. For example: &scaleFirstEntryOfTuple = scale >>> _1 =mcmc$Create a possibly tuneable proposal.>mcmcTune a 6 . Return µ if 6& is not tuneable. If the parameter dt is larger than 1.0, the 6 is enlarged, if 0<dt<1.0>, it is shrunk. Negative tuning parameters are not allowed.?mcmc Create a ) from a list of 6s.@mcmcSet the order of 6s in a ).Amcmc Replicate 67s according to their weights and possibly shuffle them.BmcmcTune 6 s in the ). See >.Cmcmc.Calculate acceptance ratios and auto tune the 6 s in the ). For now, a 6[ is enlarged when the acceptance ratio is above 0.44, and shrunk otherwise. Do not change 6s that are not tuneable.DmcmcSummarize the 6 s in the ) . Also report acceptance ratios.Emcmc$In the beginning there was the Word.8Initialize an empty storage of accepted/rejected values.FmcmcFor key k:, prepend an accepted (True) or rejected (False) proposal.GmcmcReset acceptance storage.HmcmcXTransform keys using the given lists. Keys not provided will not be present in the new ' variable.¶mcmc4Acceptance counts and ratio for a specific proposal.Imcmc$Acceptance ratios for all proposals.=mcmcName.mcmcWeight.mcmc»Function creating a simple proposal for a given tuning parameter. The larger the tuning parameter, the larger the proposal (and the lower the expected acceptance ratio), and vice versa.mcmcActivate tuning?#'()*+,-./0123456789:;<=>?@ABCDEFGHI#6789:;<345012=>+,-./)*?@ABCD'(EFGHI%Generic interface to create proposals(c) Dominik Schrempf 2020GPL-3.0-or-laterdominik.schrempf@gmail.comunstableportableNoneŠRmcmc@Generic function to create proposals for continuous parameters (´).Smcmc>Generic function to create proposals for discrete parameters (³).RmcmcProbability distributionmcmc0Forward operator, e.g. (+), so that x + dx = x'.mcmcInverse operator, e.g., ·D, so that x' + (negate dx) = x. Only required for biased proposals.SmcmcProbability distribution.mcmc0Forward operator, e.g. (+), so that x + dx = x'.mcmcInverse operator, e.g., ·D, so that x' + (negate dx) = x. Only required for biased proposals.RSRS Normally distributed proposal(c) Dominik Schrempf 2020GPL-3.0-or-laterdominik.schrempf@gmail.comunstableportableNoneSX–ýTmcmc3Additive proposal with normally distributed kernel.UmcmcÊAdditive proposal with normally distributed kernel with mean zero. This proposal is very fast, because the Metropolis-Hastings ratio does not include calculation of the forwards and backwards kernels.Vmcmc¼Additive proposal with uniformly distributed kernel. This proposal is very fast, because the Metropolis-Hastings ratio does not include calculation of the forwards and backwards kernels.TmcmcName.mcmcWeight.mcmcMean.mcmcStandard deviation.mcmcEnable tuning.UmcmcName.mcmcWeight.mcmcStandard deviation.mcmcEnable tuning.VmcmcName.mcmcWeight.mcmcDelta.mcmcEnable tuning.TUVTUV (Scaling proposal with Gamma distribution(c) Dominik Schrempf 2020GPL-3.0-or-laterdominik.schrempf@gmail.comunstableportableNoneSXŸ*Wmcmc6Multiplicative proposal with Gamma distributed kernel.Xmcmc¨Multiplicative proposal with Gamma distributed kernel. The scale of the Gamma distributions is set to (shape)^{-1}, so that the mean of the Gamma distribution is 1.0.WmcmcName.mcmcWeight.mcmcShape.mcmcScale.mcmcEnable tuning.XmcmcName.mcmcWeight.mcmcShape.mcmcEnable tuning.WXWX Bactrian proposals(c) Dominik Schrempf, 2020GPL-3.0-or-laterdominik.schrempf@gmail.comunstableportableNone­]Ymcmc\Additive symmetric proposal with kernel similar to the silhouette of a Bactrian camel. The  Ahttps://www.ncbi.nlm.nih.gov/pmc/articles/PMC3845170/figure/fig01Bactrian kernelø is a mixture of two symmetrically arranged normal distributions. The spike parameter loosely determines the standard deviations of the individual humps while the other parameter refers to the standard deviation of the complete Bactrian kernel.See  5https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3845170/.ZmcmcXMultiplicative proposal with kernel similar to the silhouette of a Bactrian camel. See Y.YmcmcName.mcmcWeight.mcmcSpike parameter.mcmcStandard deviation.mcmcEnable tuning.ZmcmcName.mcmcWeight.mcmcSpike parameter.mcmcStandard deviation.mcmcEnable tuning.YZYZ Trace of a Markov chain(c) Dominik Schrempf 2020GPL-3.0-or-laterdominik.schrempf@gmail.comunstableportableNone´a[mcmcA [O passes through a list of states with associated likelihoods which are called s. New Os are prepended, and the path of the Markov chain is stored in reversed order.\mcmcThe empty trace.]mcmc Prepend an  to a [.^mcmc&Get the most recent item of the trace._mcmc)Get the N most recent items of the trace.[\]^_[\]^_ Be quiet! Or better not?(c) Dominik Schrempf, 2020GPL-3.0-or-laterdominik.schrempf@gmail.comunstableportableNone¸ÜgmcmcNot much to say here.omcmcPerform action if g is i or higher.pmcmcPerform action if g is j or higher.qmcmcPerform action if g is k.gkjhiopqgkjhiopqMonitor a Markov chain(c) Dominik Schrempf, 2020GPL-3.0-or-laterdominik.schrempf@gmail.comunstableportableNoneÓrtmcmcYMonitor to a file, but calculate batch means for the given batch size; constructed with ~.}Batch monitors are slow at the moment because the monitored parameter has to be extracted from the state for each iteration.umcmc$Monitor to a file; constructed with }.vmcmc-Monitor to standard output; constructed with |.wmcmcA w™ describes which part of the Markov chain should be logged and where. Further, they allow output of summary statistics per iteration in a flexible way.ymcmc#Monitor writing to standard output.zmcmcMonitors writing to files.{mcmc7Monitors calculating batch means and writing to files.|mcmcMonitor to standard output.}mcmcMonitor parameters to a file.~mcmc"Monitor parameters to a file, see t.mcmc#Open the files associated with the w.€mcmc#Open the files associated with the w in append mode.mcmcGet header line of v.‚mcmcsExecute monitors; print status information to files and return text to be printed to standard output and log file.ƒmcmc$Close the files associated with the w.|mcmc+Instructions about which parameters to log.mcmcLogging period.}mcmc$Name; used as part of the file name.mcmc+Instructions about which parameters to log.mcmcLogging period.~mcmc$Name; used as part of the file name.mcmcQInstructions about which parameters to log and how to calculate the batch means.mcmc Batch size.‚mcmc Verbositymcmc Iteration.mcmcStarting state.mcmcStarting time.mcmcTrace of Markov chain.mcmc-Total number of iterations; to calculate ETA.mcmc The monitor.tuvwxyz{|}~€‚ƒwxyz{v|u}t~€‚ƒWhat is an MCMC?(c) Dominik Schrempf 2020GPL-3.0-or-laterdominik.schrempf@gmail.comunstableportableNoneú „mcmcThe „V contains all information to run an MCMC chain. It is constructed using the function ˜.†mcmc0The name of the MCMC chain; used as file prefix.‡mcmc The current E of the chain combines the current state and the current likelihood.ˆmcmc0The iteration is the number of completed cycles.‰mcmcThe [8 of the Markov chain in reverse order, the most recent  is at the head of the list.Šmcmc For each 6Š, store the list of accepted (True) and rejected (False) proposals; for reasons of efficiency, the list is also stored in reverse order.‹mcmc6Number of burn in iterations; deactivate burn in with µ.ŒmcmcGAuto tuning period (only during burn in); deactivate auto tuning with µ.mcmcbNumber of normal iterations excluding burn in. Note that auto tuning only happens during burn in.Žmcmc#Overwrite output files? Default is ¸, change with š.mcmc1Save the chain at the end of the run? Default is ¹, change with ™.mcmc Verbosity.‘mcmcThe random number generator.’mcmcSStarting time and starting iteration of chain; used to calculate run time and ETA.“mcmcHandle to log file.”mcmc`The prior function. The un-normalized posterior is the product of the prior and the likelihood.•mcmceThe likelihood function. The un-normalized posterior is the product of the prior and the likelihood.–mcmc A set of 6 s form a ).—mcmcA w observing the chain.˜mcmcInitialize the „# of a Markov chain Monte Carlo run.™mcmc(Do not save the Markov chain at the end.šmcmc5Overwrite existing files; it is not necessary to use š, when a chain is continued.›mcmczDo not print anything to standard output. Do not create log file. File monitors and batch monitors are executed normally.œmcmc Be verbose.˜ mcmc.Name of the Markov chain; used as file prefix.mcmcThe prior function.mcmcThe likelihood function.mcmc A list of 6Hs executed in forward order. The chain will be logged after each cycle.mcmcA w observing the chain.mcmc%The initial state in the state space a.mcmc6Number of burn in iterations; deactivate burn in with µ.mcmcGAuto tuning period (only during burn in); deactivate auto tuning with µ.mcmcbNumber of normal iterations excluding burn in. Note that auto tuning only happens during burn in. mcmc`A source of randomness. For reproducible runs, make sure to use a generator with the same seed.„…‰–’†‡ˆŠ‹ŒŽ‘“”•—˜™š›œ„…‰–’†‡ˆŠ‹ŒŽ‘“”•—˜™š›œ Save the state of a Markov chain(c) Dominik Schrempf, 2020GPL-3.0-or-laterdominik.schrempf@gmail.comunstableportableNone¯mcmcSave a „ to file.SSaved information: - state - iteration - trace - acceptance ratios - generatorŸImportant information that cannot be saved and has to be provided again when a chain is restored: - prior function - likelihood function - cycle - monitoržmcmcLoad a „¬ from file. Important information that cannot be saved and has to be provided again when a chain is restored: - prior function - likelihood function - cycle - monitoržž Mcmc helpers(c) Dominik Schrempf, 2020GPL-3.0-or-laterdominik.schrempf@gmail.comunstableportableNone¸¡mcmc‰An Mcmc state transformer; usually fiddling around with this type is not required, but it is used by the different inference algorithms.¢mcmc&Write to standard output and log file.£mcmc&Write to standard output and log file.¤mcmcPrint warning message.¥mcmcPrint warning message.¦mcmcPrint info message.§mcmcPrint info message.¨mcmcPrint debug message.©mcmcPrint debug message.ªmcmcAuto tune the 6 s in the )- of the chain. Reset acceptance counts. See C.«mcmcReset acceptance counts.¬mcmcPrint short summary of 6s in ). See D.­mcmc Report what is going to be done.®mcmc-Print header line of standard output monitor.¯mcmc Execute the ws of the chain. See ‚.°mcmcRun an MCMC algorithm.¡¢£¤¥¦§¨©ª«¬­®¯°¡¢£¤¥¦§¨©ª«¬­®¯°Metropolis-Hastings at its best(c) Dominik Schrempf 2020GPL-3.0-or-laterdominik.schrempf@gmail.comunstableportableNone ±mcmcHContinue a Markov chain for a given number of Metropolis-Hastings steps.²mcmcCRun a Markov chain for a given number of Metropolis-Hastings steps.±mcmc/Additional number of Metropolis-Hastings steps.mcmc"Loaded status of the Markov chain.²mcmc-Initial (or last) status of the Markov chain.±²²±7Markov chain Monte Carlo algorithms, batteries included(c) Dominik Schrempf 2020GPL-3.0-or-laterdominik.schrempf@gmail.comunstableportableNoneSXŽ4 !)+,-./6<?@TUVWXYtuvwx|}~˜™š›œž±² 6<WXTYUV)?+,-./@˜™š›œwxv|u}t~²±žSafeº»¼½¾¿ÀÁ !""#$%&'()**+,-./0123456789:;<=>?@ABCDEEFGGHIJKLMNOPQRSTUVWXYZ[\]^_`abc d e f g h i j k l m n o p q r s t u v w x y z { | } ~  € ‚ ƒ„…†‡‡ˆ‰Š‹ŒŽ‘’““”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁ¿ÀÂÃÄÅÆÃÇÈ¿ÀÉ¿ÀÊËÌÍÎÏÐÑÒÓ!mcmc-0.2.0-1Hzgic77Zhk7lKCdEXka6d Mcmc.ItemMcmc.Monitor.LogMcmc.Monitor.ParameterMcmc.Monitor.ParameterBatchMcmc.Monitor.TimeMcmc.Tools.Shuffle Mcmc.ProposalMcmc.Proposal.GenericMcmc.Proposal.SlideMcmc.Proposal.ScaleMcmc.Proposal.Bactrian Mcmc.TraceMcmc.Verbosity Mcmc.Monitor Mcmc.Status Mcmc.Save Mcmc.McmcMcmc.MetropolisMcmc Paths_mcmcItemstateprior likelihood $fFromJSONLog $fToJSONLog$fFromJSONItem $fToJSONItem$fEqItem $fOrdItem $fShowItem $fReadItem renderLogMonitorParametermpNamempFunc@. monitorIntmonitorRealFloatmonitorRealFloatFmonitorRealFloatSMonitorParameterBatchmbpNamembpFunc@#monitorBatchMeanIntmonitorBatchMeanIntFmonitorBatchMeanRealFloatmonitorBatchMeanRealFloatFmonitorBatchMeanRealFloatSmonitorBatchCustomrenderDurationrenderDurationSshuffleshuffleNgrabble AcceptancefromAcceptanceCycle ccProposalsOrderRandomO SequentialORandomReversibleOSequentialReversibleOTunertParamtFuncProposalSimplepSampleProposalpNamepWeightpSimplepTuner@~createProposaltunefromListsetOrder getNCycles tuneCycle autotuneCyclesummarizeCycleemptyApushAresetAtransformKeysAacceptanceRatios $fOrdProposal $fEqProposal$fShowProposal$fDefaultOrder$fFromJSONAcceptance$fToJSONAcceptance $fEqOrder $fShowOrderproposalGenericContinuousproposalGenericDiscreteslideslideSymmetric slideUniformscale scaleUnbiased slideBactrian scaleBactrianTrace singletonTpushTheadTtakeT$fFromJSONTrace $fToJSONTrace $fMonoidTrace$fSemigroupTrace $fShowTrace $fReadTrace $fEqTrace VerbosityQuietWarnInfoDebug$fShowVerbosity $fEqVerbosity$fOrdVerbositywarninfodebug$fFromJSONVerbosity$fToJSONVerbosity MonitorBatch MonitorFile MonitorStdOutMonitormStdOutmFilesmBatches monitorStdOut monitorFile monitorBatchmOpenmAppendmHeadermExecmCloseStatusnameitem iterationtrace acceptanceburnInIterationsautoTuningPeriod iterationsforceOverwritesave verbosity generatorstart logHandlepriorF likelihoodFcyclemonitorstatusnoSaveforcequiet saveStatus loadStatus$fFromJSONSave $fToJSONSavemcmcOutTmcmcOutS mcmcWarnT mcmcWarnS mcmcInfoT mcmcInfoS mcmcDebugT mcmcDebugS mcmcAutotune mcmcResetAmcmcSummarizeCycle mcmcReportmcmcMonitorStdOutHeadermcmcMonitorExecmcmcRun mhContinuemhghc-prim GHC.TypesIntDoublebase GHC.MaybeNothingacceptanceRatioGHC.NumnegateFalseTrueversion getBinDir getLibDir getDynLibDir getDataDir getLibexecDir getSysconfDirgetDataFileName