úÎ!FŖ;Ŋ      !"#$%&'()*+,-./0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e fghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ĄĸŖ¤Ĩϧ¨ŠĒĢŦ­Ž¯°ą˛ŗ´ĩšēģŧ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.comunstableportableNonermcmcPrint 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.mcmc:Convert a parameter monitor from one data type to another.For example, to monitor a Ŋ( value being the first entry of a tuple: mon = fst @. 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: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.mcmc@Convert a batch parameter monitor from one data type to another.EFor example, to batch monitor the mean of the first entry of a tuple: mon = fst @# monitorBatchMean 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?W$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.$%$%'Convenience functions to compute priors(c) Dominik Schrempf, 2020GPL-3.0-or-laterdominik.schrempf@gmail.comunstableportableNoneJX&mcmc&Improper uniform prior; larger than 0.'mcmc%Improper uniform prior; lower than 0.(mcmcUniform prior on [a, b].)mcmcNormal distributed prior.*mcmcExponential distributed prior.+mcmcGamma distributed prior.,mcmc8Intelligent product that stops when encountering a zero.™Use with care because the elements have to be checked for positiveness, and this can take some time if the list is long and does not contain any zeroes.(mcmcLower bound a.mcmcUpper bound b.)mcmcMean.mcmcStandard deviation.*mcmcRate.+mcmcShape.mcmcScale.&'()*+,&'()*+,Shuffle a list(c) Dominik Schrempf 2020GPL-3.0-or-laterdominik.schrempf@gmail.comunstableportableNoneOU-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Œ•0mcmc For each key k6, store the number of accepted and rejected proposals.2mcmc In brief, a 2 is a list of proposals.<The state of the Markov chain will be logged only after all ? s in the 2b have been completed, and the iteration counter will be increased by one. The order in which the ? s are executed is specified by 4. The default is 5. Proposals must have unique names!, so that they can be identified.4mcmcDefine the order in which ?s are executed in a 2. The total number of ?s per 2 may differ between 4s (e.g., compare 5 and 7).5mcmc Shuffle the ? s in the 2. The ?Ps are replicated according to their weights and executed in random order. If a ? has weight w, it is executed exactly w times per iteration.6mcmcThe ?>s are executed sequentially, in the order they appear in the 2. ?s with weight w>1 are repeated immediately w2 times (and not appended to the end of the list).7mcmc Similar to 55. However, a reversed copy of the list of shuffled ?`s is appended such that the resulting Markov chain is reversible. Note: the total number of ?.s executed per cycle is twice the number of 5.8mcmc Similar to 6@. However, a reversed copy of the list of sequentially ordered ?Bs is appended such that the resulting Markov chain is reversible.9mcmcTune the acceptance ratio of a ?; see G, or L.<mcmc+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.?mcmcA ?M 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 ?| may be tuneable in that it contains information about how to enlarge or shrink the step size to tune the acceptance ratio.Amcmc7Name (no proposals with the same name are allowed in a 2).Bmcmc"The weight determines how often a ?0 is executed per iteration of the Markov chain.Cmcmc=Simple proposal without name, weight, and tuning information.DmcmcTuning is disabled if set to ŋ.Emcmc>Convert a proposal from one data type to another using a lens. For example: &scaleFirstEntryOfTuple = scale >>> _1 Fmcmc$Create a possibly tuneable proposal.GmcmcTune a ? . Return ŋ if ?& is not tuneable. If the parameter dt is larger than 1.0, the ? is enlarged, if 0<dt<1.0>, it is shrunk. Negative tuning parameters are not allowed.Hmcmc Create a 2 from a list of ?s.ImcmcSet the order of ?s in a 2.Jmcmc Replicate ?7s according to their weights and possibly shuffle them.KmcmcTune ? s in the 2. See G.Lmcmc.Calculate acceptance ratios and auto tune the ? s in the 2. For now, a ?[ is enlarged when the acceptance ratio is above 0.44, and shrunk otherwise. Do not change ?s that are not tuneable.MmcmcSummarize the ? s in the 2 . Also report acceptance ratios.Nmcmc$In the beginning there was the Word.8Initialize an empty storage of accepted/rejected values.OmcmcFor key k:, prepend an accepted (True) or rejected (False) proposal.PmcmcReset acceptance storage.QmcmcXTransform keys using the given lists. Keys not provided will not be present in the new 0 variable.Āmcmc4Acceptance counts and ratio for a specific proposal.Rmcmc$Acceptance ratios for all proposals.FmcmcName.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:;<=>?@ABCDEFGHIJKLMNOPQR#?@ABCDE<=>9:;FG4567823HIJKLM01NOPQR %Generic interface to create proposals(c) Dominik Schrempf 2020GPL-3.0-or-laterdominik.schrempf@gmail.comunstableportableNone˜ [mcmc@Generic function to create proposals for continuous parameters (Ŋ).\mcmc>Generic function to create proposals for discrete parameters (ž).[mcmcProbability 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.\mcmcProbability 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.[\[\ Normally distributed proposal(c) Dominik Schrempf 2020GPL-3.0-or-laterdominik.schrempf@gmail.comunstableportableNoneSXŠE]mcmc3Additive proposal with normally distributed kernel.^mcmcĘ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._mcmcŧ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.`mcmc3Additive proposal with normally distributed kernel.ƒThe two values are slid contrarily so that their sum stays constant. Contrary proposals are useful when parameters are confounded.]mcmcName.mcmcWeight.mcmcMean.mcmcStandard deviation.mcmcEnable tuning.^mcmcName.mcmcWeight.mcmcStandard deviation.mcmcEnable tuning._mcmcName.mcmcWeight.mcmcDelta.mcmcEnable tuning.`mcmcName.mcmcWeight.mcmcMean.mcmcStandard deviation.mcmcEnable tuning.]^_`]^_` (Scaling proposal with Gamma distribution(c) Dominik Schrempf 2020GPL-3.0-or-laterdominik.schrempf@gmail.comunstableportableNoneSXĩÃamcmc6Multiplicative proposal with Gamma distributed kernel.bmcmc6Multiplicative proposal with Gamma distributed kernel.pThe scale of the Gamma distributions is set to (shape)^{-1}, so that the mean of the Gamma distribution is 1.0.cmcmc6Multiplicative proposal with Gamma distributed kernel.‰The two values are scaled contrarily so that their product stays constant. Contrary proposals are useful when parameters are confounded.amcmcName.mcmcWeight.mcmcShape.mcmcScale.mcmcEnable tuning.bmcmcName.mcmcWeight.mcmcShape.mcmcEnable tuning.cmcmcName.mcmcWeight.mcmcShape.mcmcScale.mcmcEnable tuning.abcabc Bactrian proposals(c) Dominik Schrempf, 2020GPL-3.0-or-laterdominik.schrempf@gmail.comunstableportableNoneÃūdmcmc\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/.emcmcXMultiplicative proposal with kernel similar to the silhouette of a Bactrian camel. See d.dmcmcName.mcmcWeight.mcmcSpike parameter.mcmcStandard deviation.mcmcEnable tuning.emcmcName.mcmcWeight.mcmcSpike parameter.mcmcStandard deviation.mcmcEnable tuning.dedeTrace of a Markov chain(c) Dominik Schrempf 2020GPL-3.0-or-laterdominik.schrempf@gmail.comunstableportableNoneˤfmcmcA fO 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.gmcmcThe empty trace.hmcmc Prepend an  to a f.imcmc&Get the most recent item of the trace.jmcmc)Get the N most recent items of the trace.kmcmc"Shorten the trace to given length.fghijkfghijkBe quiet! Or better not?(c) Dominik Schrempf, 2020GPL-3.0-or-laterdominik.schrempf@gmail.comunstableportableNoneĐ'smcmcNot much to say here.{mcmcPerform action if s is u or higher.|mcmcPerform action if s is v or higher.}mcmcPerform action if s is w.swvtu{|}swvtu{|}Monitor a Markov chain(c) Dominik Schrempf, 2020GPL-3.0-or-laterdominik.schrempf@gmail.comunstableportableNoneęJ€mcmcYMonitor 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.mcmc$Monitor to a file; constructed with ‰.‚mcmc-Monitor to standard output; constructed with ˆ.ƒmcmcA ƒ™ 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 €.‹mcmc#Open the files associated with the ƒ.Œmcmc#Open the files associated with the ƒ in append mode.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 ƒ.ˆ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.€‚ƒ„…†‡ˆ‰Š‹ŒŽƒ„…†‡‚ˆ‰€Š‹ŒŽ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 f8 of the Markov chain in reverse order, the most recent  is at the head of the list.•mcmc For each ?Š, 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 Ĩ.šmcmcVSave the chain with trace of given length at the end of the run? Default is no save (ŋ). 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 ? s form a 2.ĸmcmcA ƒ observing the chain.ŖmcmcInitialize the # of a Markov chain Monte Carlo run.¤mcmc1Save the Markov chain with trace of given length.Ĩ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 ?Hs executed in forward order. The chain will be logged after each cycle.mcmcA ƒ 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.comunstableportableNonef¨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(To avoid incomplete continued runs, the .mcmc file is removed after load.¨Š¨Š 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 ? s in the 2- of the chain. Reset acceptance counts. See L.ļmcmcReset acceptance counts.ˇmcmcPrint short summary of ?s in 2. See M.¸mcmc Report what is going to be done.šmcmc Execute the ƒs of the chain. See .ēmcmcRun an MCMC algorithm.Ŧ­Ž¯°ą˛ŗ´ĩšēŦ­Ž¯°ą˛ŗ´ĩšēMetropolis-Hastings at its best(c) Dominik Schrempf 2020GPL-3.0-or-laterdominik.schrempf@gmail.comunstableportableNone75ģmcmcHContinue a Markov chain for a given number of Metropolis-Hastings steps.6At the moment, when an MCMC run is continued, the old .mcmc: file is deleted. This behavior may change in the future.˙This means that an interrupted continuation also breaks previous runs. This step is necessary because, otherwise, incomplete monitor files are left on disk, if a continuation is canceled. Subsequent continuations would append to the incomplete monitor files and produce garbage.ŧ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.comunstableportableNoneSX9ē9 !"#&'()*+,245678?EHI]^_abd€‚ƒ„ˆ‰ŠŖ¤ĨϧŠģŧ ?Eab]d^_2H45678IŖ¤Ĩϧƒ„‚ˆ‰€ŠŧģŠSafe;\ÃÄÅÆĮČÉĘË !"#$%&'(()*+,-./00123456789:;<=>?@ABC D E F G H I J K L M N O P P Q R R S T 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 t u v wxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”••–—˜™š›œžŸ  ĄĸŖ¤Ĩϧ¨ŠĒĢŦ­Ž¯°ą˛ŗ´ĩļˇ¸šēģŧŊžŋĀÁÂÃÄÅÆĮČÉĘËĖÍËĖÎĪĐŅ ŌĪĶÔËĖÕÖרŲÚÛÜŨŪ!mcmc-0.2.3-8YThDTPOVKj3R5JiIRONRBMcmc.Internal.ByteString Mcmc.ItemMcmc.Monitor.LogMcmc.Monitor.ParameterMcmc.Monitor.ParameterBatchMcmc.Monitor.Time Mcmc.PriorMcmc.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@#monitorBatchMeanmonitorBatchMeanFmonitorBatchMeanEmonitorBatchCustomrenderDurationrenderDurationSpositivenegativeuniformnormal exponentialgammaproduct'shuffleshuffleNgrabble AcceptancefromAcceptanceCycle ccProposalsOrderRandomO SequentialORandomReversibleOSequentialReversibleOTunertParamtFuncProposalSimplepSampleProposalpNamepWeightpSimplepTuner@~createProposaltunefromListsetOrdergetNIterations tuneCycle autotuneCyclesummarizeCycleemptyApushAresetAtransformKeysAacceptanceRatios $fOrdProposal $fEqProposal$fShowProposal$fDefaultOrder$fFromJSONAcceptance$fToJSONAcceptance $fEqOrder $fShowOrdergenericContinuousgenericDiscreteslideslideSymmetric slideUniformslideContrarilyscale scaleUnbiasedscaleContrarily slideBactrian scaleBactrianTrace singletonTpushTheadT takeItemstakeT$fFromJSONTrace $fToJSONTrace $fMonoidTrace$fSemigroupTrace $fShowTrace $fReadTrace $fEqTrace VerbosityQuietWarnInfoDebug$fShowVerbosity $fEqVerbosity$fOrdVerbositywarninfodebug$fFromJSONVerbosity$fToJSONVerbosity MonitorBatch MonitorFile MonitorStdOutMonitormStdOutmFilesmBatches monitorStdOut monitorFile monitorBatchmOpenmAppendmExecmCloseStatusnameitem iterationtrace acceptanceburnInIterationsautoTuningPeriod iterationsforceOverwritesave verbosity generatorstart logHandlepriorF likelihoodFcyclemonitorstatussaveWithforcequiet saveStatus loadStatus$fFromJSONSave $fToJSONSavemcmcOutTmcmcOutS mcmcWarnT mcmcWarnS mcmcInfoT mcmcInfoS mcmcDebugT mcmcDebugS mcmcAutotune mcmcResetAmcmcSummarizeCycle mcmcReportmcmcMonitorExecmcmcRun mhContinuemhghc-prim GHC.TypesDoubleIntbase GHC.MaybeNothingacceptanceRatioGHC.NumnegateFalseversion getBinDir getLibDir getDynLibDir getDataDir getLibexecDir getSysconfDirgetDataFileName