1
$\begingroup$

Recently I was looking at a paper where the velocity auto-correlation function $$C(t) = \langle v_x(t) v_x(0) \rangle = \langle \cos\theta(t), \cos \theta(0) \rangle$$ was being considered for a number of point particles with velocities distributed uniformly on $S^1$ at time zero (here $\langle \cdot \rangle$ denotes an average over initial conditions). In the above, $\theta(t)$ is the angle w.r.t to the horizontal at time $t$. In their plot of $C(t)$ vs. $t$ I noticed that $C(0) \ne 1/2$ (there were multiple plots). However I don't see this when trying to generate a uniform velocity distribution so I assume I am doing something wrong here.

I generate velocities uniformly on $S^1$ as follows:

    N <- 10^4                                          # number of samples
    r <- runif(N, 0, 1)                                # uniform radii in [0,1]
    theta <- runif(N, -pi, pi)                         # uniform angles
    P <- cbind(sqrt(r)*cos(theta), sqrt(r)*sin(theta)) # uniform points in the unit disk
    L <- sqrt(P[,1]*P[,1] + P[,2]*P[,2]) 
    V <- P/L 

Another method I've seen is:

X1 <- rnorm(N, 0, 1)
X2 <- rnorm(N, 0, 1)
R  <- sqrt(X1*X1 + X2*X2)
V  <- matrix(rbind(X1/R, X2/R), N, 2, byrow=TRUE)

Or using the pracma package:

pracma::rands(N, r=1.0, N=1.0)

Firstly, can someone confirm that these are appropriate methods for generating points uniformly on the unit circle?

In all cases mean(V[,1] * V[,1]) returns $\approx 1/2$.

Moreover if $\Theta \sim \mathcal{U}[-\pi, \pi]$ and $V = \cos^2 \Theta$ then it has the pdf $$f_V(x) = \dfrac{-2}{\pi} \dfrac{d}{dx} (\sin^{-1} \sqrt{x}) = \dfrac{-1}{\sqrt{x(1-x)}}$$ which has mean value $$\int_0^1 x f_V(x) dx = 1/2.$$

Is this correct?

Edit:

The issue with the final calculation is that uniform points on the circle are not formed by simply taking the cosine and sine of uniformly distributed angles, so it must be incorrect..

$\endgroup$
1
$\begingroup$

Integration over initial condition also gives $1/2$. $$ C(0) = \left< \cos \theta, \cos \theta\right> = \frac{\int_{-\pi}^{\pi} \cos^2 \theta \, d\theta }{ \int_{-\pi}^{\pi} \, d\theta} = \frac{1}{2} $$

It could be that in the paper it is normalized by $C(0)$.

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ And does the code do as suggested? $\endgroup$ – algae May 24 at 3:24
  • $\begingroup$ @algae both of your codes do not sample from $S^1$. I think the simple way is to take cosine and sine of runif(N, -pi, pi). $\endgroup$ – slitvinov May 24 at 8:40
  • $\begingroup$ AFAIK that is the classic mistake that is made when sampling points uniformly on $S^1$. The first code is based on the paper here. $\endgroup$ – algae May 24 at 8:51
  • $\begingroup$ Interesting. Is it incorrect in theory, computational inefficient, or not robust to floating point precision? $\endgroup$ – slitvinov May 24 at 9:26
  • $\begingroup$ Incorrect in theory. Cosine and sine of uniform angles do not give uniform points on the circle. $\endgroup$ – algae May 24 at 9:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.