úÎ!*Ë ľ      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRST U V W X Y Z [ \ ] ^ _ ` a b c d e f g h ijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ Ą˘Ł¤ĽŚ§¨ŠŞŤŹ­ŽŻ°ą˛ł´ByteString tools(c) Dominik Schrempf, 2020GPL-3.0-or-laterdominik.schrempf@gmail.comunstableportableSafe‚mcmcnFor a given width, align string to the right; use given fill character; trim on the left if string is longer.mcmcTFor a given width, align string to the right; trim on the left if string is longer.mcmcnFor a given width, align string to the left; use given fill character; trim on the right if string is longer.mcmcTFor a given width, align string to the left; trim on the right if string is longer.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.comunstableportableNone mcmcPrint a log value.Monitor parameters(c) Dominik Schrempf, 2020GPL-3.0-or-laterdominik.schrempf@gmail.comunstableportableNoneSX%Ź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.For example, to monitor a ľ( value being the first entry of a tuple: mon = _1 @@ monitorDouble mcmcMonitor ś.mcmcMonitor ľ, with eight decimal places (half precision).mcmcMonitor ľb with full precision computing the shortest string of digits that correctly represent the number.mcmcMonitor ľ* in exponential format and half precision.mcmcName.mcmcName.mcmcName.mcmcName.  Monitor parameters(c) Dominik Schrempf, 2020GPL-3.0-or-laterdominik.schrempf@gmail.comunstableportableNoneSX:nmcmcë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 mcmcIBatch monitor. Print the mean with eight decimal places (half precision).!mcmcBatch monitor. Print the mean with full precision computing the shortest string of digits that correctly represent the number."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.!mcmcName."mcmcName.#mcmcName.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.comunstableportableNoneD€&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x)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 8 s in the +b have been completed, and the iteration counter will be increased by one. The order in which the 8 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 8s are executed in a +. The total number of 8s per + may differ between -s (e.g., compare . and 0)..mcmc Shuffle the 8 s in the +. The 8Ps are replicated according to their weights and executed in random order. If a 8 has weight w, it is executed exactly w times per iteration./mcmcThe 8>s are executed sequentially, in the order they appear in the +. 8s with weight w>1 are repeated immediately w2 times (and not appended to the end of the list).0mcmc Similar to .5. However, a reversed copy of the list of shuffled 8`s is appended such that the resulting Markov chain is reversible. Note: the total number of 8.s executed per cycle is twice the number of ..1mcmc Similar to /@. However, a reversed copy of the list of sequentially ordered 8Bs is appended such that the resulting Markov chain is reversible.2mcmcTune the acceptance ratio of a 8; see @, or E.5mcmc+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.8mcmcA 8M 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 8| may be tuneable in that it contains information about how to enlarge or shrink the step size to tune the acceptance ratio.:mcmc7Name (no proposals with the same name are allowed in a +).;mcmc"The weight determines how often a 80 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 8 . Return ˇ if 8& is not tuneable. If the parameter dt is larger than 1.0, the 8 is enlarged, if 0<dt<1.0>, it is shrunk. Negative tuning parameters are not allowed.Amcmc Create a + from a list of 8s.BmcmcSet the order of 8s in a +.Cmcmc Replicate 87s according to their weights and possibly shuffle them.DmcmcTune 8 s in the +. See @.Emcmc.Calculate acceptance ratios and auto tune the 8 s in the +. For now, a 8[ is enlarged when the acceptance ratio is above 0.44, and shrunk otherwise. Do not change 8s that are not tuneable.FmcmcSummarize the 8 s in the + . Also report acceptance ratios.Gmcmc$In the beginning there was the Word.8Initialize an empty storage of accepted/rejected values.HmcmcFor key k:, prepend an accepted (True) or rejected (False) proposal.ImcmcReset acceptance storage.JmcmcXTransform keys using the given lists. Keys not provided will not be present in the new ) variable.¸mcmc4Acceptance counts and ratio for a specific proposal.Kmcmc$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:;<=>?@ABCDEFGHIJK#89:;<=>567234?@-./01+,ABCDEF)*GHIJK %Generic interface to create proposals(c) Dominik Schrempf 2020GPL-3.0-or-laterdominik.schrempf@gmail.comunstableportableNoneŒďTmcmc@Generic function to create proposals for continuous parameters (ľ).Umcmc>Generic function to create proposals for discrete parameters (ś).TmcmcProbability 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.UmcmcProbability 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.TUTU Normally distributed proposal(c) Dominik Schrempf 2020GPL-3.0-or-laterdominik.schrempf@gmail.comunstableportableNoneSX™ĎVmcmc3Additive proposal with normally distributed kernel.WmcmcĘ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.Xmcmcź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.VmcmcName.mcmcWeight.mcmcMean.mcmcStandard deviation.mcmcEnable tuning.WmcmcName.mcmcWeight.mcmcStandard deviation.mcmcEnable tuning.XmcmcName.mcmcWeight.mcmcDelta.mcmcEnable tuning.VWXVWX (Scaling proposal with Gamma distribution(c) Dominik Schrempf 2020GPL-3.0-or-laterdominik.schrempf@gmail.comunstableportableNoneSXĄüYmcmc6Multiplicative proposal with Gamma distributed kernel.Zmcmc¨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.YmcmcName.mcmcWeight.mcmcShape.mcmcScale.mcmcEnable tuning.ZmcmcName.mcmcWeight.mcmcShape.mcmcEnable tuning.YZYZ Bactrian proposals(c) Dominik Schrempf, 2020GPL-3.0-or-laterdominik.schrempf@gmail.comunstableportableNone°/[mcmc\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/.\mcmcXMultiplicative proposal with kernel similar to the silhouette of a Bactrian camel. See [.[mcmcName.mcmcWeight.mcmcSpike parameter.mcmcStandard deviation.mcmcEnable tuning.\mcmcName.mcmcWeight.mcmcSpike parameter.mcmcStandard deviation.mcmcEnable tuning.[\[\ Trace of a Markov chain(c) Dominik Schrempf 2020GPL-3.0-or-laterdominik.schrempf@gmail.comunstableportableNoneˇ3]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.amcmc)Get the N most recent items of the trace.]^_`a]^_`aBe quiet! Or better not?(c) Dominik Schrempf, 2020GPL-3.0-or-laterdominik.schrempf@gmail.comunstableportableNoneťŽimcmcNot much to say here.qmcmcPerform action if i is k or higher.rmcmcPerform action if i is l or higher.smcmcPerform action if i is m.imljkqrsimljkqrsMonitor a Markov chain(c) Dominik Schrempf, 2020GPL-3.0-or-laterdominik.schrempf@gmail.comunstableportableNoneÖDvmcmcYMonitor 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.wmcmc$Monitor to a file; constructed with .xmcmc-Monitor to standard output; constructed with ~.ymcmcA y™ 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.{mcmc#Monitor writing to standard output.|mcmcMonitors 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 v.mcmc#Open the files associated with the y.‚mcmc#Open the files associated with the y in append mode.ƒmcmcGet header line of x.„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 y.~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.vwxyz{|}~€‚ƒ„…yz{|}x~wv€‚ƒ„…What is an MCMC?(c) Dominik Schrempf 2020GPL-3.0-or-laterdominik.schrempf@gmail.comunstableportableNoneýr†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 8Š, 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 8 s form a +.™mcmcA y 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 8Hs executed in forward order. The chain will be logged after each cycle.mcmcA y 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 8 s in the +- of the chain. Reset acceptance counts. See E.­mcmcReset acceptance counts.ŽmcmcPrint short summary of 8s in +. See F.Żmcmc Report what is going to be done.°mcmc-Print header line of standard output monitor.ąmcmc Execute the ys 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`2 !"#+-./018>ABVWXYZ[vwxyz~€š›œž ł´ 8>YZV[WX+A-./01Bš›œžyzx~wv€´ł Safećź˝žżŔÁÂĂÄ !"#$%&''()*+,-.//0123456789:;<=>?@ABCDEFGHHIJJKLMNOPQRSTUVWXYZ[\]^_`abcd e f g h i j k l m n o p q r s t u v w x yz{|}~€‚ƒ„…†‡ˆ‰ŠŠ‹ŒŽ‘’“”•––—˜™š›œžŸ Ą˘Ł¤ĽŚ§¨ŠŞŤŹ„­ŽŻ°ą˛ł´ľśˇ¸šşťź˝žżŔÁÂĂÄÂĂĹĆÇČÉĆĘËÂĂĚÂĂÍÎĎĐŃŇÓÔŐÖ mcmc-0.2.1-vhinEiIoWs62nTQkf9f8LMcmc.Internal.ByteString 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_mcmcalignRightWith alignRight alignLeftWith alignLeftItemstateprior likelihood $fFromJSONLog $fToJSONLog$fFromJSONItem $fToJSONItem$fEqItem $fOrdItem $fShowItem $fReadItem renderLogMonitorParametermpNamempFunc@. monitorInt monitorDoublemonitorDoubleFmonitorDoubleEMonitorParameterBatchmbpNamembpFunc@#monitorBatchMeanmonitorBatchMeanFmonitorBatchMeanEmonitorBatchCustomrenderDurationrenderDurationSshuffleshuffleNgrabble 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.TypesDoubleIntbase GHC.MaybeNothingacceptanceRatioGHC.NumnegateFalseTrueversion getBinDir getLibDir getDynLibDir getDataDir getLibexecDir getSysconfDirgetDataFileName