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 to return samples using Hamiltonian Monte Carlo
  
  Parameters
  ----------
  initial_pos: A 1d array like object
    Vector representing values of parameter position, the starting
    state in markov chain.
  
  num_samples: int
    Number of samples to be generated
  
  trajectory_length: int or float
    Target trajectory length, stepsize * number of steps(L),
    where L is the number of steps taken per HMC iteration,
    and stepsize is step size for splitting time method.
  
  stepsize: float, defaults to None
    The stepsize for proposing new values of position and momentum in simulate_dynamics
    If None, then will be choosen suitably
  
  burn: int, defaults to 1000
    Number of samples to ignore in the beginning
docstr_tok: ["Method","to","return","samples","using","Hamiltonian","Monte","Carlo","Parameters","--","--","--","--","--","initial_pos",":","A","1d","array","like","object","Vector","representing","values","of","parameter","position",",","the","starting","state","in","markov","chain",".","num_samples",":","int","Number","of","samples","to","be","generated","trajectory_length",":","int","or","float","Target","trajectory","length",",","stepsize","*","number","of","steps","(","L",")",",","where","L","is","the","number","of","steps","taken","per","HMC","iteration",",","and","stepsize","is","step","size","for","splitting","time","method",".","stepsize",":","float",",","defaults","to","None","The","stepsize","for","proposing","new","values","of","position","and","momentum","in","simulate_dynamics","If","None",",","then","will","be","choosen","suitably","burn",":","int",",","defaults","to","1000","Number","of","samples","to","ignore","in","the","beginning"]
code: def sample(
      self,
      initial_pos,
      num_samples,
      trajectory_length,
      stepsize=None,
      burn=1000,
  ):
      """
      Method to return samples using Hamiltonian Monte Carlo
  
      Parameters
      ----------
      initial_pos: A 1d array like object
        Vector representing values of parameter position, the starting
        state in markov chain.
  
      num_samples: int
        Number of samples to be generated
  
      trajectory_length: int or float
        Target trajectory length, stepsize * number of steps(L),
        where L is the number of steps taken per HMC iteration,
        and stepsize is step size for splitting time method.
  
      stepsize: float, defaults to None
        The stepsize for proposing new values of position and momentum in simulate_dynamics
        If None, then will be choosen suitably
  
      burn: int, defaults to 1000
        Number of samples to ignore in the beginning
      """
  
      self.accepted_proposals = 1.0
      initial_pos = _check_1d_array_object(initial_pos, "initial_pos")
  
      if stepsize is None:
          stepsize = self._find_reasonable_stepsize(initial_pos)
  
      # samples = np.zeros(num_samples, dtype=types).view(np.recarray)
      samples = np.zeros(num_samples, dtype=float)
  
      # Assigning after converting into tuple because value was being
      # changed after assignment. Reason for this is unknown
      position_m = initial_pos
  
      lsteps = int(max(1, round(trajectory_length / stepsize, 0)))
      for i in range(1, num_samples + burn + 1):
          # Genrating sample
          position_m, _ = self._sample(
              position_m, trajectory_length, stepsize, lsteps
          )
          # ignore first few samples
          if i >= burn:
              samples[i - burn - 1] = position_m
  
      self.acceptance_rate = self.accepted_proposals / num_samples
  
      return samples
  
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 6 for calling the HamiltonianMC obj's underlying member method code with example usage: obj.sample(initial_pos, num_samples, trajectory_length, stepsize, burn) and returns: samples