class_docstr: Class for performing sampling in Continuous model
  using No U Turn Sampler (a variant of Hamiltonian Monte Carlo)
  
  Parameters
  ----------
  model: An instance pgmpy.models
      Model from which sampling has to be done
  
  grad_log_pdf: A subclass of pgmpy.inference.continuous.GradientLogPDF
      Class to compute the log and gradient log of distribution
  
  simulate_dynamics: A subclass of pgmpy.inference.continuous.BaseSimulateHamiltonianDynamics
      Class to propose future states of position and momentum in time by simulating
      HamiltonianDynamics
  
  Public Methods
  --------------
  sample()
  generate_sample()
  
  Example
  -------
  >>> from pgmpy.sampling import NoUTurnSampler as NUTS, LeapFrog, GradLogPDFGaussian
  >>> from pgmpy.factors.continuous import GaussianDistribution as JGD
  >>> import numpy as np
  >>> mean = np.array([1, 2, 3])
  >>> covariance = np.array([[4, 0.1, 0.2], [0.1, 1, 0.3], [0.2, 0.3, 8]])
  >>> model = JGD(['x', 'y', 'z'], mean, covariance)
  >>> sampler = NUTS(model=model, grad_log_pdf=GradLogPDFGaussian, simulate_dynamics=LeapFrog)
  >>> samples = sampler.sample(initial_pos=np.array([0.1, 0.9, 0.3]), num_samples=20000,
  ...                          stepsize=0.4, return_type='recarray')
  >>> samples
  rec.array([(0.1, 0.9, 0.3),
   (-0.27303886844752756, 0.5028580705249155, 0.2895768065049909),
   (1.7139810571103862, 2.809135711303245, 5.690811523613858), ...,
   (-0.7742669710786649, 2.092867703984895, 6.139480724333439),
   (1.3916152816323692, 1.394952482021687, 3.446906546649354),
   (-0.2726336476939125, 2.6230854954595357, 2.923948403903159)],
            dtype=[('x', '<f8'), ('y', '<f8'), ('z', '<f8')])
  
  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
  Algorithm 3 : Efficient No-U-Turn Sampler
class_docstr_tok: ["Class","for","performing","sampling","in","Continuous","model","using","No","U","Turn","Sampler","(","a","variant","of","Hamiltonian","Monte","Carlo",")","Parameters","--","--","--","--","--","model",":","An","instance","pgmpy.models","Model","from","which","sampling","has","to","be","done","grad_log_pdf",":","A","subclass","of","pgmpy.inference.continuous.GradientLogPDF","Class","to","compute","the","log","and","gradient","log","of","distribution","simulate_dynamics",":","A","subclass","of","pgmpy.inference.continuous.BaseSimulateHamiltonianDynamics","Class","to","propose","future","states","of","position","and","momentum","in","time","by","simulating","HamiltonianDynamics","Public","Methods","--","--","--","--","--","--","--","sample","(",")","generate_sample","(",")","Example","--","--","--","-",">",">",">","from","pgmpy.sampling","import","NoUTurnSampler","as","NUTS",",","LeapFrog",",","GradLogPDFGaussian",">",">",">","from","pgmpy.factors.continuous","import","GaussianDistribution","as","JGD",">",">",">","import","numpy","as","np",">",">",">","mean","=","np.array","(","[","1",",","2",",","3","]",")",">",">",">","covariance","=","np.array","(","[","[","4",",","0.1",",","0.2","]",",","[","0.1",",","1",",","0.3","]",",","[","0.2",",","0.3",",","8","]","]",")",">",">",">","model","=","JGD","(","[","'","x","'",",","'","y","'",",","'","z","'","]",",","mean",",","covariance",")",">",">",">","sampler","=","NUTS","(","model=model",",","grad_log_pdf=GradLogPDFGaussian",",","simulate_dynamics=LeapFrog",")",">",">",">","samples","=","sampler.sample","(","initial_pos=np.array","(","[","0.1",",","0.9",",","0.3","]",")",",","num_samples=20000",",","...","stepsize=0.4",",","return_type='recarray","'",")",">",">",">","samples","rec.array","(","[","(","0.1",",","0.9",",","0.3",")",",","(","-0.27303886844752756",",","0.5028580705249155",",","0.2895768065049909",")",",","(","1.7139810571103862",",","2.809135711303245",",","5.690811523613858",")",",","...",",","(","-0.7742669710786649",",","2.092867703984895",",","6.139480724333439",")",",","(","1.3916152816323692",",","1.394952482021687",",","3.446906546649354",")",",","(","-0.2726336476939125",",","2.6230854954595357",",","2.923948403903159",")","]",",","dtype=","[","(","'","x","'",",","'","<","f8","'",")",",","(","'","y","'",",","'","<","f8","'",")",",","(","'","z","'",",","'","<","f8","'",")","]",")","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","Algorithm","3",":","Efficient","No-U-Turn","Sampler"]
code: def _update_acceptance_criteria(
      self,
      position_forward,
      position_backward,
      momentum_forward,
      momentum_backward,
      accept_set_bool,
      candidate_set_size,
      candidate_set_size2,
  ):
      # criteria1 = I[(θ+ − θ−)·r− ≥ 0]
      criteria1 = (
          np.dot(
              (position_forward - position_backward), momentum_backward
          )
          >= 0
      )
  
      # criteira2 = I[(θ+ − θ− )·r+ ≥ 0]
      criteria2 = (
          np.dot(
              (position_forward - position_backward), momentum_forward
          )
          >= 0
      )
  
      accept_set_bool = accept_set_bool and criteria1 and criteria2
      candidate_set_size += candidate_set_size2
  
      return accept_set_bool, candidate_set_size
  
file_path: pgmpy/pgmpy/sampling/NUTS.py
imports: import numpy
  from tqdm.auto import tqdm
  from pgmpy.sampling import HamiltonianMCDA, LeapFrog, _return_samples
  from pgmpy.utils import _check_1d_array_object, _check_length_equal
label_desc: Use image node_id 3 for calling the NoUTurnSampler obj's underlying member method code with example usage: obj._update_acceptance_criteria(position_forward, position_backward, momentum_forward, momentum_backward, accept_set_bool, candidate_set_size, candidate_set_size2) and returns: accept_set_bool,  candidate_set_size