altar.cuda.bayesian.cudaAdaptiveMetropolis
Module Contents
Classes
- class altar.cuda.bayesian.cudaAdaptiveMetropolis.cudaAdaptiveMetropolis(name, locator, **kwds)
Bases:
altar.componentThe Adaptive Metropolis algorithm from Thomas Catanach Compared with traditional MCMC, there are two modifications: 1. After certain steps (corr_check_steps), the correlation between the current and the starting samples is computed. If the correlation is less than a threshold value (target_correlation), i.e., the chains are effectively de-correlated, the MCMC stops. max_mc_steps provides a maximum MCMC step 2. The scaling factor (scaling) targets an optimal acceptance rate
- scaling
- doc = scaling factor σ for Gaussian proposal ~ N(0, σ^2 Σ), initial value 2.38/sqrt(N_d)
- scaling_min
- doc = the minimum value of the scaling factor
- scaling_max
- doc = the maximum value of the scaling factor
- parameters
- doc = total number of parameters N_d
- target_acceptance_rate
- doc = the targeted acceptance rate
- gain
- doc = Feedback gain constant
- max_mc_steps
- doc = the maximum Monte-Carlo steps for one beta step
- min_mc_steps
- doc = the minimum Monte-Carlo steps for one beta step
- max_mc_steps_stage2
- doc = the maximum Monte-Carlo steps at stage 2, or beta> beta_stage2
- beta_stage2
- doc = beta value to start stage 2, i.e., to use a different max_mc_steps
- corr_check_steps
- doc = the Monte-Carlo steps to compute the de
- target_correlation
- doc = the threshold of correlation to stop the chain
- mcsteps = 1
- dispatcher
- ginit = False
- gstep
- gcandidate
- gproposal
- gsigma_chol
- gvalid_indices
- gvalid_samples
- ginvalid_flags
- gacceptance_flags
- precision
- gdice
- curng
- initialize(self, application)
Initialize me and my parts given an {application} context
- cuInitialize(self, application)
- samplePosterior(self, annealer, step)
Sample the posterior distribution :param annealer - the controller: :param step - cpu CoolingStep:
- Returns:
statistics (accepted/rejected/invalid) or (accepted/unlikely/rejected)
- resample(self, annealer, statistics)
Update my statistics based on the results of walking my Markov chains
- prepareSamplingPDF(self, annealer, step)
Re-scale and decompose the parameter covariance matrix, in preparation for the Metropolis update
- finishSamplingPDF(self, step)
procedures after sampling, e.g, copy data back to cpu
- walkChains(self, annealer, step)
Run the Metropolis algorithm on the Markov chains :param annealer: cudaAnnealer :param step: cudaCoolingStep
- Returns:
statistics = (accepted, rejected, unlikely)
- displace(self, displacement)
Construct a set of displacement vectors for the random walk from a distribution with zero mean and my covariance
- adjustCovarianceScaling(self, accepted, invalid, rejected)
Compute a new value for the covariance sacling factor based on the acceptance/rejection ratio
- allocateGPUData(self, samples, parameters)
initialize gpu work data
- static gainFunction(x)
Compute the optimal gain constant from a target acceptranceRate {x}