Question regarding "sample(psi)". subroutine

Hi,

My question is very basic and it might be a clarification. The question is related to routine “sample”
samp = sample!(psi)
new_state = [samp[j] == 1 ? “Z+” : “Z-” for j in 1:N]

I picked this code line from metts example code.

Is it the similar sampling which I discuss below?
so, probability of being in spin z up state is given by P_up = <psi| Sz | psi> + 0.5
then we generate a random number “r”. If P_up > r then I project to up state and if
P_up < r then I project to down state.

Is the sample!(psi) does the same job as I discussed above?

Please clarify this for me.

Best
Aman

1 Like

Yes, your understanding is exactly correct. Note that S^z+0.5 is the projection operator on the “up” spin state so more generally one can formulate the sampling for any site dimension in terms of a set of similar projectors.

Thank you for the quick response.
I was implementing the METTS algorithm on Kitaev Honeycomb model and tried it for a small system size. But it did not worked, I tested flux(W_p). which is product of 6 spin operator comes out to be highly fluctuating in each typical thermal state step. It seems METTS does not work for such quantities which fluctuates rapidly, energy seems to be decent quantity which can converge.
Since, you have experience on METTS algorithm can you comment on it why it does not work or may be I made a mistake in code.

May be I should change the topic name to METTS .

Thank you
Aman