def leapfrog(H, q, p, epsilon, n_steps):
 def full_update(p, q):
  p = (p + (epsilon * H.dlogp(q)))
  q += (epsilon * H.pot.velocity(p))
  return (p, q)
 p = (p + ((0.5 * epsilon) * H.dlogp(q)))
 q += (epsilon * H.pot.velocity(p))
 if tt.gt(n_steps, 1):
  ((p_seq, q_seq), _) = theano.scan(full_update, outputs_info=[p, q], n_steps=(n_steps - 1))
  (p, q) = (p_seq[(-1)], q_seq[(-1)])
 p += ((0.5 * epsilon) * H.dlogp(q))
 return (q, p)

def leapfrog ( H , q , p , epsilon , n_steps ) : def full_update ( p , q ) : p = ( p + ( epsilon * H . dlogp ( q ) ) ) q += ( epsilon * H . pot . velocity ( p ) ) return ( p , q ) p = ( p + ( ( 0.5 * epsilon ) * H . dlogp ( q ) ) ) q += ( epsilon * H . pot . velocity ( p ) ) if tt . gt ( n_steps , 1 ) : ( ( p_seq , q_seq ) , _ ) = theano . scan ( full_update , outputs_info = [ p , q ] , n_steps = ( n_steps - 1 ) ) ( p , q ) = ( p_seq [ ( - 1 ) ] , q_seq [ ( - 1 ) ] ) p += ( ( 0.5 * epsilon ) * H . dlogp ( q ) ) return ( q , p )
leapfrog integrator .