In a computer program (written in C++), given $x\in[0,1)$ and $\sigma>0$, I need to sample $y$ from the wrapped normal distribution $\mathcal W_{x,\:\sigma^2}$ with mean $x$ and variance $\sigma^2$ and evaluate the density $q$ of $\mathcal W_{x,\:\sigma^2}$ at $y$ at the same time.
If $\varphi_{\sigma^2}$ denotes the density of the normal distribution with mean $0$ and variance $\sigma^2$ and $$\psi_{\sigma^2}(y):=\sum_{k\in\mathbb Z}\varphi_{\sigma^2}(k+y)\;\;\;\text{for }y\in\mathbb R,$$ then $$q(y):=\psi_{\sigma^2}(y-x)\;\;\;\text{for }y\in[0,1)$$ is the density of $\mathcal W_{x,\:\sigma^2}$ with respect to the Lebesgue measure.
We can sample $y$ by drawing $\xi\sim\mathcal N_{0,\:1}$, setting $z:=x+\sigma\xi$ and $y:=z-\lfloor z\rfloor$. But now I would need to evaluate $q(y)$ separately.
So, my question is: Can we somehow sample $y$ in a clever way such that we obtain $q(y)$ as a byproduct? If not, how should we evaluate $q(y)$ (the problematic thing being that it's an infinite sum)?
R, just apply this function to a vector of the data:function(x) {y <- (x-x[1]+1/2) %% 1; c((mean(y)+x[1]-1/2) %% 1, sd(y))})Assuming $\sigma \ll 1$ ($\sigma \lt 1/10$ should work well), it will provide an accurate estimate of the mean and sd. – whuber Jan 09 '20 at 14:06RI'm not able to fully understand your code ;) – 0xbadf00d Jan 09 '20 at 15:17Csyntax is that%%reduces a value modulo $1.$ – whuber Jan 09 '20 at 15:18