code stringlengths 3 6.57k |
|---|
phmc.sample_nd(nsamps, initstate, stepsize, ninits) |
collections.namedtuple("MCMCState", "state logdens loggrad loghess") |
MetropolisHastings(ABC) |
__init__(self, logdens) |
sample_nd(self, nsamps, init_state, pwidth, ninits=None, *optional) |
a (d,) |
np.zeros((nsamps, len(init_state) |
np.zeros(nsamps) |
self.evaluate_logdens(init_state) |
range(1, nsamps) |
self.generate_proposal(currstate, pwidth) |
self.generate_proposal(currstate, 0.2 * pwidth) |
currstate.state.copy() |
currstate.logdens.copy() |
int(is_accept) |
evaluate_logdens(self, loc) |
self.logdens.eval(loc) |
self.logdens.gradeval(loc) |
self.logdens.hesseval(loc) |
accept_or_reject(self, currstate, proposal, corrfact, idx, ninits) |
self.get_logaccprob(currstate, proposal, corrfact, idx, ninits) |
np.log(np.random.rand() |
get_logaccprob(self, currstate, proposal, corrfact, idx, ninits) |
return (corrfact) |
generate_proposal(self, *args) |
init_state_is_array(init_state) |
an (d,) |
isinstance(init_state, np.ndarray) |
shape (d,) |
len(init_state.shape) |
shape (d,) |
RandomWalkMH(MetropolisHastings) |
__init__(self, logdens) |
MetropolisHastings.__init__(self, logdens) |
generate_proposal(self, currstate, pwidth) |
self.sample_randomwalk(currstate.state, pwidth) |
self.evaluate_logdens(newloc) |
sample_randomwalk(self, mean, var) |
np.sqrt(var) |
np.random.randn(len(mean) |
LangevinMH(MetropolisHastings) |
__init__(self, logdens) |
MetropolisHastings.__init__(self, logdens) |
generate_proposal(self, currstate, pwidth) |
self.sample_langevin(currstate, pwidth) |
self.evaluate_logdens(newloc) |
self.compute_corrfact_langevin(currstate, proposal, pwidth) |
sample_langevin(self, currstate, pwidth) |
np.random.randn(len(currstate.state) |
np.sqrt(2 * pwidth) |
compute_corrfact_langevin(self, currstate, proposal, pwidth) |
self.kernel_langevin(currstate, proposal, pwidth) |
self.kernel_langevin(proposal, currstate, pwidth) |
kernel_langevin(self, state1, state2, pwidth) |
np.linalg.norm(state1.state - state2_dyn) |
PrecondLangevinMH(MetropolisHastings) |
with (inverse) |
__init__(self, logdens) |
M (and not M^{-1}) |
MetropolisHastings.__init__(self, logdens) |
generate_proposal(self, currstate, pwidth) |
self.sample_langevin(currstate, pwidth) |
self.evaluate_logdens(newloc) |
self.compute_corrfact_langevin(currstate, proposal, pwidth) |
sample_langevin(self, currstate, pwidth) |
np.zeros(len(currstate.loghess) |
np.linalg.inv(currstate.loghess) |
np.linalg.solve(currstate.loghess, currstate.loggrad) |
np.sqrt(2 * pwidth) |
compute_corrfact_langevin(self, currstate, proposal, pwidth) |
self.kernel_langevin(currstate, proposal, pwidth) |
self.kernel_langevin(proposal, currstate, pwidth) |
kernel_langevin(self, state1, state2, pwidth) |
np.linalg.solve(state2.loghess, state2.loggrad) |
difference.dot(np.dot(state2.loghess, difference) |
HamiltonianMC(MetropolisHastings) |
__init__(self, logdens, nsteps) |
MetropolisHastings.__init__(self, logdens) |
generate_proposal(self, currstate, pwidth) |
np.zeros(len(currstate.state) |
np.eye(len(currstate.state) |
self.evaluate_hamiltonian(momentum, currstate) |
self.leapfrog_dynamics(momentum, currstate, pwidth) |
self.evaluate_hamiltonian(momentum_new, proposal) |
self.get_corrfact(momentum, momentum_new) |
leapfrog_dynamics(self, momentum, currstate, pwidth) |
range(self.nsteps) |
self.compute_next_lfstep(momentum, proposal, pwidth) |
compute_next_lfstep(self, momentum, proposal, pwidth) |
self.evaluate_logdens(pstate) |
get_corrfact(self, mom_new, mom) |
PrecondHamiltonianMC(MetropolisHastings) |
__init__(self, logdens, nsteps) |
M (and not M^{-1}) |
MetropolisHastings.__init__(self, logdens) |
generate_proposal(self, currstate, pwidth) |
np.zeros(len(currstate.state) |
self.leapfrog_dynamics(momentum, currstate, pwidth) |
self.get_corrfact(momentum, momentum_new, currstate, proposal) |
leapfrog_dynamics(self, momentum, currstate, pwidth) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.