# Changing randomly a unit vector

For studying a spin model on a lattice, I have to generate a random unit vector starting from a pre-exstisting one. There are multiple ways to do it, but the book I use suggests generating a random displacement vector $$\Delta\boldsymbol{S}=\Delta S_{max}(p_1,p_2,p_3)$$ with $$p_i$$ three random numbers in $$[-1,1]$$ and $$\Delta S_{max}$$ a parameter, then adding the displacement to the original vector and normalizing the sum. What I don't understand is the following. The authors say to check if $$|\Delta\boldsymbol{S}|>\Delta S_{max}$$ and generate another displacement if this condition is verified. They say that:

This latter step is necessary to insure that the change in a spin direction is symmetrically distributed around the current spin direction.

Here, the current spin is the pre-existing unit vector. I don't see what they mean with the sentence quoted basically. Why do I need to do that check?

The book is "Introduction to Computer Simulation Methods" by Harvey Gould, Jan Tobochnik, and Wolfgang Christian.

• What book is this procedure from? What is the value of S_max? Is it just a parameter or does it have some interpretation? Jun 17, 2021 at 1:09
• I've added this information in the post Jun 17, 2021 at 7:36

What you’re seeing is a basic acceptance-rejection method. $$\Delta S$$ generated in that way will be uniform in the ball of radius $$\Delta S_{\text{max}}$$ centered at the origin.

I imagine you're doing some kind of optimization by random search, in which case the goal is to find a set of spins that extremize some objective function. The way it looks is that you have an initial spin, $$S$$, and want to explore the improvement a random variation of it yields. In this case $$\Delta S_{\text{max}}$$ give you a sort of maximum step size, and the vector $$S + \Delta S$$, with $$\Delta S$$ generated as you describe, gives you a new candidate after you normalize it. If $$\Delta S_{\text{max}}$$ is small, say much smaller than 1, the new candidate will be pretty close to the initial one.
• But why would I care about $\Delta \boldsymbol{S}$ being generated in a sphere? After generating the displacement, I sum it to the original vector and then normalize the sum. I guess in some way without this requirement the final normalized vector wouldn't be uniformly distributed on the unit sphere but I can't see why. Jun 17, 2021 at 7:32
• Given $\mathbf{S}$ is a unit vector and the generation of $\mathbf{\Delta S}$, it is conceivable that $\mathbf{\Delta S}=-\mathbf{S}$. If accepted, this change would stop the spin immediately, which may not be physical. I suspect that $\Delta S_{\max}$ is strictly (and significantly) smaller than $1$ to guarantee a smooth transition (of course, if $|\cdot|$ is the Euclidean vector norm). Jun 17, 2021 at 13:30
• I could just put a check for the condition $\Delta\boldsymbol{S}=-\boldsymbol{S}$ for that though. It could be that the authors suggest doing that so to have smooth changes, but it is not what they have written and actually changes that are too smooth might generate other problems in my case (I'm using a Metropolis algorithm and ergodicity is implied. If spin changes are too smooth I think this assumption becomes shaky). Jun 17, 2021 at 13:53
• That will depend on $\Delta S_{\max}$; maybe if it is too small, I would be concerned. However, I don't know if it is actually an issue. Afaik, there are smooth ergodic functions, and small updates to the spin may be generating one of those. Jun 17, 2021 at 15:20