I am currently coding a 3D (Monte-Carlo) implementation of the Ising model, using the single spin-flip & Wolff algorithm.
So far, I was able to calculate all the interesting observables, like $M$ and $\chi$.
Now I want to implement the two-point-correlation function, but I am struggling here both in understanding the function itself and how to code it.
So in David Landau and Kurt Binder's book "A guide to Monte-Carlo simulations in statistical physics" (2021), they introduce the two-point correlation function as follows:
$$\Gamma(r) = \langle \rho(0) \cdot \rho(r) \rangle$$
where $r$ is the spatial distance and $\rho$ is the quantity whose correlation is being measured. So from my understanding, this should then look like this in the Ising model:
$$\Gamma(r) = \langle \sigma_{0} \cdot \sigma_{i} \rangle$$
Where $\sigma_{0}$ would be an arbitrarily chosen spin, called "origin site".
Now I am confused because I don't see how one should think of this in terms of Monte-Carlo simulations. Does that mean I choose (in each iteration) one (random?) $\sigma_{0}$ spin and calculate its product with another random spin ($\sigma_{i}$) and save that value to calculate the mean over all iterations later? Is it always the same spin, in a sense the two-point function is always calculated for a "specific radius $r$", where $r$ is set by $\sigma_i$?
Or do I take the sum of that product over all possible spins, in that sense:
$$\langle \sigma_{0} \cdot \sigma_{i} \rangle = \frac{1}{N}\sum_{i}^N \sigma_{0} \cdot \sigma_{i}$$ for each iteration?
Then, on the other hand I see this formulation in that thread here: $$\sum_{i,j} \left[ \langle \sigma_i \cdot \sigma_j \rangle - \langle \sigma_i \rangle \cdot \langle \sigma_j \rangle \right]$$
which confuses me even more, because now where is the "origin site" $\sigma_0$? Where does that formula come from?
Thank you.