class_docstr: A sampler for continuous variables based on Hamiltonian mechanics.
  
  See NUTS sampler for automatically tuned stopping time and step size scaling.
class_docstr_tok: ["A","sampler","for","continuous","variables","based","on","Hamiltonian","mechanics",".","See","NUTS","sampler","for","automatically","tuned","stopping","time","and","step","size","scaling","."]
docstr: Set up the Hamiltonian Monte Carlo sampler.
  
  Parameters
  ----------
  vars: list, default=None
      List of value variables. If None, all continuous RVs from the
      model are included.
  path_length: float, default=2
      Total length to travel
  step_rand: function float -> float, default=unif
      A function which takes the step size and returns a new one used to
      randomize the step size at each iteration. The default draws a random
      new step size from a uniform distribution with +-15% of the given one.
      If set to None, no randomization is done.
  step_scale: float, default=0.25
      Initial size of steps to take, automatically scaled down by 1/n**(1/4)
      where n is the dimensionality of the parameter space
  scaling: array_like, ndim = {1,2}
      The inverse mass, or precision matrix. One dimensional arrays are
      interpreted as diagonal matrices. If `is_cov` is set to True,
      this will be interpreted as the mass or covariance matrix.
  is_cov: bool, default=False
      Treat the scaling as mass or covariance matrix.
  potential: Potential, optional
      An object that represents the Hamiltonian with methods `velocity`,
      `energy`, and `random` methods. It can be specified instead
      of the scaling matrix.
  target_accept: float, default 0.65
      Adapt the step size such that the average acceptance
      probability across the trajectories are close to target_accept.
      Higher values for target_accept lead to smaller step sizes.
      Setting this to higher values like 0.9 or 0.99 can help
      with sampling from difficult posteriors. Valid values are
      between 0 and 1 (exclusive). Default of 0.65 is from (Beskos et.
      al. 2010, Neal 2011). See Hoffman and Gelman's "The No-U-Turn
      Sampler: Adaptively Setting Path Lengths in Hamiltonian Monte
      Carlo" section 3.2 for details.
  gamma: float, default .05
  k: float, default .75
      Parameter for dual averaging for step size adaptation. Values
      between 0.5 and 1 (exclusive) are admissible. Higher values
      correspond to slower adaptation.
  t0: float > 0, default 10
      Parameter for dual averaging. Higher values slow initial
      adaptation.
  adapt_step_size: bool, default=True
      Whether step size adaptation should be enabled. If this is
      disabled, `k`, `t0`, `gamma` and `target_accept` are ignored.
  max_steps: int
      The maximum number of leapfrog steps.
  model: pymc.Model
      The model
  **kwargs: passed to BaseHMC
docstr_tok: ["Set","up","the","Hamiltonian","Monte","Carlo","sampler",".","Parameters","--","--","--","--","--","vars",":","list",",","default=None","List","of","value","variables",".","If","None",",","all","continuous","RVs","from","the","model","are","included",".","path_length",":","float",",","default=2","Total","length","to","travel","step_rand",":","function","float","-",">","float",",","default=unif","A","function","which","takes","the","step","size","and","returns","a","new","one","used","to","randomize","the","step","size","at","each","iteration",".","The","default","draws","a","random","new","step","size","from","a","uniform","distribution","with","+-15","%","of","the","given","one",".","If","set","to","None",",","no","randomization","is","done",".","step_scale",":","float",",","default=0.25","Initial","size","of","steps","to","take",",","automatically","scaled","down","by","1\/n","*","*","(","1\/4",")","where","n","is","the","dimensionality","of","the","parameter","space","scaling",":","array_like",",","ndim","=","{","1,2","}","The","inverse","mass",",","or","precision","matrix",".","One","dimensional","arrays","are","interpreted","as","diagonal","matrices",".","If","`","is_cov","`","is","set","to","True",",","this","will","be","interpreted","as","the","mass","or","covariance","matrix",".","is_cov",":","bool",",","default=False","Treat","the","scaling","as","mass","or","covariance","matrix",".","potential",":","Potential",",","optional","An","object","that","represents","the","Hamiltonian","with","methods","`","velocity","`",",","`","energy","`",",","and","`","random","`","methods",".","It","can","be","specified","instead","of","the","scaling","matrix",".","target_accept",":","float",",","default","0.65","Adapt","the","step","size","such","that","the","average","acceptance","probability","across","the","trajectories","are","close","to","target_accept",".","Higher","values","for","target_accept","lead","to","smaller","step","sizes",".","Setting","this","to","higher","values","like","0.9","or","0.99","can","help","with","sampling","from","difficult","posteriors",".","Valid","values","are","between","0","and","1","(","exclusive",")",".","Default","of","0.65","is","from","(","Beskos","et",".","al",".","2010",",","Neal","2011",")",".","See","Hoffman","and","Gelman","'s","``","The","No-U-Turn","Sampler",":","Adaptively","Setting","Path","Lengths","in","Hamiltonian","Monte","Carlo","''","section","3.2","for","details",".","gamma",":","float",",","default",".05","k",":","float",",","default",".75","Parameter","for","dual","averaging","for","step","size","adaptation",".","Values","between","0.5","and","1","(","exclusive",")","are","admissible",".","Higher","values","correspond","to","slower","adaptation",".","t0",":","float",">","0",",","default","10","Parameter","for","dual","averaging",".","Higher","values","slow","initial","adaptation",".","adapt_step_size",":","bool",",","default=True","Whether","step","size","adaptation","should","be","enabled",".","If","this","is","disabled",",","`","k","`",",","`","t0","`",",","`","gamma","`","and","`","target_accept","`","are","ignored",".","max_steps",":","int","The","maximum","number","of","leapfrog","steps",".","model",":","pymc.Model","The","model","*","*","kwargs",":","passed","to","BaseHMC"]
code: def __init__(
      self, vars=None, path_length=2.0, max_steps=1024, **kwargs
  ):
      """
      Set up the Hamiltonian Monte Carlo sampler.
  
      Parameters
      ----------
      vars: list, default=None
          List of value variables. If None, all continuous RVs from the
          model are included.
      path_length: float, default=2
          Total length to travel
      step_rand: function float -> float, default=unif
          A function which takes the step size and returns a new one used to
          randomize the step size at each iteration. The default draws a random
          new step size from a uniform distribution with +-15% of the given one.
          If set to None, no randomization is done.
      step_scale: float, default=0.25
          Initial size of steps to take, automatically scaled down by 1/n**(1/4)
          where n is the dimensionality of the parameter space
      scaling: array_like, ndim = {1,2}
          The inverse mass, or precision matrix. One dimensional arrays are
          interpreted as diagonal matrices. If `is_cov` is set to True,
          this will be interpreted as the mass or covariance matrix.
      is_cov: bool, default=False
          Treat the scaling as mass or covariance matrix.
      potential: Potential, optional
          An object that represents the Hamiltonian with methods `velocity`,
          `energy`, and `random` methods. It can be specified instead
          of the scaling matrix.
      target_accept: float, default 0.65
          Adapt the step size such that the average acceptance
          probability across the trajectories are close to target_accept.
          Higher values for target_accept lead to smaller step sizes.
          Setting this to higher values like 0.9 or 0.99 can help
          with sampling from difficult posteriors. Valid values are
          between 0 and 1 (exclusive). Default of 0.65 is from (Beskos et.
          al. 2010, Neal 2011). See Hoffman and Gelman's "The No-U-Turn
          Sampler: Adaptively Setting Path Lengths in Hamiltonian Monte
          Carlo" section 3.2 for details.
      gamma: float, default .05
      k: float, default .75
          Parameter for dual averaging for step size adaptation. Values
          between 0.5 and 1 (exclusive) are admissible. Higher values
          correspond to slower adaptation.
      t0: float > 0, default 10
          Parameter for dual averaging. Higher values slow initial
          adaptation.
      adapt_step_size: bool, default=True
          Whether step size adaptation should be enabled. If this is
          disabled, `k`, `t0`, `gamma` and `target_accept` are ignored.
      max_steps: int
          The maximum number of leapfrog steps.
      model: pymc.Model
          The model
      **kwargs: passed to BaseHMC
      """
      kwargs.setdefault("step_rand", unif)
      kwargs.setdefault("target_accept", 0.65)
      super().__init__(vars, **kwargs)
      self.path_length = path_length
      self.max_steps = max_steps
  
file_path: pymc/pymc/step_methods/hmc/hmc.py
imports: from __future__ import annotations
  from typing import Any
  import numpy
  from pymc.stats.convergence import SamplerWarning
  from pymc.step_methods.compound import Competence
  from pymc.step_methods.hmc.base_hmc import BaseHMC, DivergenceInfo, HMCStepData
  from pymc.step_methods.hmc.integration import IntegrationError, State
  from pymc.vartypes import discrete_types
label_desc: Use image node_id 1 to create a new HamiltonianMC object from inherited base classes: BaseHMC with example: obj = HamiltonianMC(vars, path_length, max_steps)