# Help using Turing for Lattice Path Integral Calculations

**URL:** https://discourse.julialang.org/t/help-using-turing-for-lattice-path-integral-calculations/59777
**Category:** New to Julia
**Tags:** turing
**Created:** [April 22, 2021, 5:09am UTC](https://discourse.julialang.org/t/help-using-turing-for-lattice-path-integral-calculations/59777 "2021-04-22T05:09:35Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![jdhooghe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jdhooghe/32/9976_2.png) [@jdhooghe](https://discourse.julialang.org/u/jdhooghe)
#### Post date: [April 22, 2021, 5:09am UTC](https://discourse.julialang.org/t/help-using-turing-for-lattice-path-integral-calculations/59777/1 "2021-04-22T05:09:35Z")

</div>

Hello everyone,

I am hoping to gain some insight into a particular problem I want to solve which I’ve done using PyMC3 but I lack the insight at the moment to make it working using Turing/AdvancedHMC. While not the problem I want to solve, it is similar. The PyMC3 code below is the Ising model on a 2-dimensional lattice.:

```julia
with pm.Model() as Model:
         R = pm.Bernoulli("R", 0.5, shape=[Nx, Ny])
         Spins = 2*R-1
         H = Hamiltonian(Spins)
         P = pm.Potential("Probability", exp(-H/T) )
         
         Step = pm.BinaryMetropolis([R], scaling = Some_Number)
         Trace = pm.sample(Number_of_Iterations, step = Step, chains = 1)

```

If I were to code this by hand, I would accept-reject a spin configuration based on the relative probability of

```julia
P = exp(-(H_New - H_Old)/T)

```

if H\_New \> H\_Old and accept it if H\_New \< H\_Old

but I want to use the new samplers instead and the wonderful utilities offered by turing.

**Question: How would I code the above Potential function in Turing/AdvancedHMC without having to specify an observed in a likelihood?**

Thank you for your time.
