class_docstr: Class for performing sampling using simple
  Hamiltonian Monte Carlo
  
  Parameters:
  -----------
  model: Model from which sampling has to be done
  
  simulate_dynamics: A class to propose future values of
    momentum and position in time by simulating
    Hamiltonian Dynamics
  
  References
  ----------
  R.Neal. Handbook of Markov Chain Monte Carlo,
  chapter 5: MCMC Using Hamiltonian Dynamics.
  CRC Press, 2011.
class_docstr_tok: ["Class","for","performing","sampling","using","simple","Hamiltonian","Monte","Carlo","Parameters",":","--","--","--","--","--","-","model",":","Model","from","which","sampling","has","to","be","done","simulate_dynamics",":","A","class","to","propose","future","values","of","momentum","and","position","in","time","by","simulating","Hamiltonian","Dynamics","References","--","--","--","--","--","R.Neal",".","Handbook","of","Markov","Chain","Monte","Carlo",",","chapter","5",":","MCMC","Using","Hamiltonian","Dynamics",".","CRC","Press",",","2011","."]
docstr: Method for choosing initial value of stepsize
  
  References
  -----------
  Matthew D. Hoffman, Andrew Gelman, The No-U-Turn Sampler: Adaptively
  Setting Path Lengths in Hamiltonian Monte Carlo. Journal of
  Machine Learning Research 15 (2014) 1351-1381
docstr_tok: ["Method","for","choosing","initial","value","of","stepsize","References","--","--","--","--","--","-","Matthew","D.","Hoffman",",","Andrew","Gelman",",","The","No-U-Turn","Sampler",":","Adaptively","Setting","Path","Lengths","in","Hamiltonian","Monte","Carlo",".","Journal","of","Machine","Learning","Research","15","(","2014",")","1351-1381"]
code: def _find_reasonable_stepsize(self, position, stepsize_app=1):
      """
      Method for choosing initial value of stepsize
  
      References
      -----------
      Matthew D. Hoffman, Andrew Gelman, The No-U-Turn Sampler: Adaptively
      Setting Path Lengths in Hamiltonian Monte Carlo. Journal of
      Machine Learning Research 15 (2014) 1351-1381
      """
      # momentum = N(0, I)
      momentum = np.reshape(
          np.random.normal(0, 1, len(position)), position.shape
      )
  
      # Take a single step in time
      position_bar, momentum_bar, _ = self.simulate_dynamics(
          self.model, position, momentum, stepsize_app
      ).get_proposed_values()
  
      acceptance_prob = self._acceptance_prob(
          position, position_bar, momentum, momentum_bar
      )
  
      # a = 2I[acceptance_prob] -1
      # a = 2*(acceptance_prob > 0.5) - 1
      a = 2 * (acceptance_prob > np.log(0.5)) - 1
  
      condition = self._get_condition(acceptance_prob, a)
  
      while condition:
          stepsize_app = np.power(2.0, a) * stepsize_app
  
          position_bar, momentum_bar, _ = self.simulate_dynamics(
              self.model, position, momentum, stepsize_app
          ).get_proposed_values()
  
          acceptance_prob = self._acceptance_prob(
              position, position_bar, momentum, momentum_bar
          )
  
          condition = self._get_condition(acceptance_prob, a)
  
      return stepsize_app
  
file_path: dragonfly/dragonfly/sampling/hmc.py
imports: from __future__ import division
  from math import sqrt
  import numpy
  from .check_functions import _check_1d_array_object
  from .base import LeapFrog, BaseSimulateHamiltonianDynamics
label_desc: Use image node_id 4 for calling the HamiltonianMC obj's underlying member method code with example usage: obj._find_reasonable_stepsize(position, stepsize_app) and returns: stepsize_app