# Bumps 1.0.0a13 documentation

## convergence - Convergence tests

`burn_point` | Determines the point at which the MCMC chain seems to have converged.
`ks_converged` | Return True if the MCMC has converged according to the K-S window test.

## Convergence diagnostics

The function `burn_point()` returns the point within the MCMC chain at which the chain can be said to have converged, or -1 if the log probabilities are still improving throughout the chain.

bumps.dream.convergence.burn_point(state: MCMCDraw, method: str = 'window', trials: int = 5, **kwargs: dict) → int

  Determines the point at which the MCMC chain seems to have converged.

  state contains the MCMC chain information.

  method=”window” is the name of the convergence diagnostic (see below).

  trials is the number of times to run the K-S test.

  Returns the index of the burn points, or -1 if no good burn point is found.

  Kolmogorov-Smirnov sliding window

  The “window” method detects convergence by comparing the distribution of \(\log(p)\) values in a small window at the start of the chains and the values in a section at the end of the chain using a Kolmogorov-Smirnov test. See `ks_converged()` for a description of the parameters.

bumps.dream.convergence.ks_converged(state: MCMCDraw, trials: int = 5, density: float = 0.6, alpha: float = 0.01, samples: int = 1000) → bool

  Return True if the MCMC has converged according to the K-S window test.

  Since we are only looking at the distribution of logp values, and not the individual points, we should be relatively stable regardless of the properties of the sampler. The main reason for failure will be “stuck” fits which have not had a chance to jump to a lower minimum.

  state contains the MCMC chain information.

  trials is the number of times to run the K-S test.

  density is the proportion of samples to select from the window. Prefer lower density from larger number of samples so the sets chosen for the K-S test have fewer duplicates. For density=0.1 about 5% of samples will be duplicates. For density=0.6 about 25% will be duplicates.

  alpha is the significance level for the test. With smaller alpha values the K-S test is less likely to reject the current window when testing against the tail of the distribution, and so the fit will end earlier, with more samples after the burn point.

  samples is the size of the sample window. If the window is too big the test will falsly end burn when the start of the window is still converging. If the window is too small the test will take a long time, and will start to show effects of autocorrelation (efficient MCMC samplers move slowly across the posterior probability space, showing short term autocorrelation between samples.) A minimum of 10 generations and a maximum of 1/2 the generations will be used.

  There is a strong interaction between density, alpha, samples and trials. If the K-S test has too many points (=density*samples), it will often reject simply because the different portions of the Markov chain are not identical (Markov chains can have short range correlations yet still have the full chain as a representative draw from the posterior distribution) unless alpha is reduced. With fewer points, the estimated K-S statistic will have more variance, and so more trials will be needed to avoid spurious accept/reject decisions.