class_docstr: Class for simulating hamiltonian dynamics using leapfrog method
  Inherits pgmpy.inference.base_continuous.BaseSimulateHamiltonianDynamics
  
  Parameters
  ----------
  model : An instance of pgmpy.models
      Model for which DiscretizeTime object is initialized
  
  position : A 1d array like object (numpy.ndarray or list)
      Vector representing values of parameter position( or X)
  
  momentum: A 1d array like object (numpy.ndarray or list)
      Vector representing the proposed value for momentum (velocity)
  
  stepsize: Float
      stepsize for the simulating dynamics
  
  grad_log_pdf : A subclass of pgmpy.inference.continuous.BaseGradLogPDF, defaults to None
      A class for evaluating gradient log and log of distribution for a given assignment of variables
      If None, then model.get_gradient_log_pdf will be used
  
  grad_log_position: A 1d array like object, defaults to None
      Vector representing gradient log at given position
      If None, then will be calculated
  
  Example
  --------
  >>> from pgmpy.factors.continuous import GaussianDistribution
  >>> from pgmpy.sampling import LeapFrog, GradLogPDFGaussian as GLPG
  >>> import numpy as np
  >>> pos = np.array([2, 1])
  >>> momentum = np.array([7, 7])
  >>> mean = np.array([-5, 5])
  >>> covariance = np.array([[1, 2], [2, 1]])
  >>> model = GaussianDistribution(['x', 'y'], mean, covariance)
  >>> new_pos, new_momentum, new_grad = LeapFrog(model, pos, momentum, 4.0, GLPG).get_proposed_values()
  >>> new_pos
  array([ 70., -19.])
  >>> new_momentum
  array([  99., -121.])
  >>> new_grad
  array([ 41., -58.])
class_docstr_tok: ["Class","for","simulating","hamiltonian","dynamics","using","leapfrog","method","Inherits","pgmpy.inference.base_continuous.BaseSimulateHamiltonianDynamics","Parameters","--","--","--","--","--","model",":","An","instance","of","pgmpy.models","Model","for","which","DiscretizeTime","object","is","initialized","position",":","A","1d","array","like","object","(","numpy.ndarray","or","list",")","Vector","representing","values","of","parameter","position","(","or","X",")","momentum",":","A","1d","array","like","object","(","numpy.ndarray","or","list",")","Vector","representing","the","proposed","value","for","momentum","(","velocity",")","stepsize",":","Float","stepsize","for","the","simulating","dynamics","grad_log_pdf",":","A","subclass","of","pgmpy.inference.continuous.BaseGradLogPDF",",","defaults","to","None","A","class","for","evaluating","gradient","log","and","log","of","distribution","for","a","given","assignment","of","variables","If","None",",","then","model.get_gradient_log_pdf","will","be","used","grad_log_position",":","A","1d","array","like","object",",","defaults","to","None","Vector","representing","gradient","log","at","given","position","If","None",",","then","will","be","calculated","Example","--","--","--","--",">",">",">","from","pgmpy.factors.continuous","import","GaussianDistribution",">",">",">","from","pgmpy.sampling","import","LeapFrog",",","GradLogPDFGaussian","as","GLPG",">",">",">","import","numpy","as","np",">",">",">","pos","=","np.array","(","[","2",",","1","]",")",">",">",">","momentum","=","np.array","(","[","7",",","7","]",")",">",">",">","mean","=","np.array","(","[","-5",",","5","]",")",">",">",">","covariance","=","np.array","(","[","[","1",",","2","]",",","[","2",",","1","]","]",")",">",">",">","model","=","GaussianDistribution","(","[","'","x","'",",","'","y","'","]",",","mean",",","covariance",")",">",">",">","new_pos",",","new_momentum",",","new_grad","=","LeapFrog","(","model",",","pos",",","momentum",",","4.0",",","GLPG",")",".get_proposed_values","(",")",">",">",">","new_pos","array","(","[","70.",",","-19",".","]",")",">",">",">","new_momentum","array","(","[","99.",",","-121",".","]",")",">",">",">","new_grad","array","(","[","41.",",","-58",".","]",")"]
docstr: Method to perform time splitting using leapfrog
docstr_tok: ["Method","to","perform","time","splitting","using","leapfrog"]
code: def _get_proposed_values(self):
      """
      Method to perform time splitting using leapfrog
      """
      # Take half step in time for updating momentum
      momentum_bar = (
          self.momentum + 0.5 * self.stepsize * self.grad_log_position
      )
  
      # Take full step in time for updating position
      position_bar = self.position + self.stepsize * momentum_bar
  
      grad_log, _ = self.grad_log_pdf(
          position_bar, self.model
      ).get_gradient_log_pdf()
  
      # Take remaining half step in time for updating momentum
      momentum_bar = momentum_bar + 0.5 * self.stepsize * grad_log
  
      return position_bar, momentum_bar, grad_log
  
imports: import itertools
  import math
  import os
  import networkx
  import numpy
  import pandas
  from joblib import Parallel, delayed
  from pgmpy.inference import Inference
  from pgmpy.utils import _check_1d_array_object, _check_length_equal, compat_fns
label_desc: Use image node_id 2 for calling the LeapFrog obj's underlying member method code with example usage: obj._get_proposed_values() and returns: position_bar,  momentum_bar,  grad_log