Timeline for Can we sample from the wrapped normal distribution and evaluate the density of the sample simultaneously?
Current License: CC BY-SA 4.0
15 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jan 9, 2020 at 15:41 | comment | added | Severin Pappadeux | How about researchgate.net/publication/… ? | |
Jan 9, 2020 at 15:18 | comment | added | whuber♦ |
About the only explanation it needs for someone familiar with C syntax is that %% reduces a value modulo $1.$
|
|
Jan 9, 2020 at 15:17 | comment | added | 0xbadf00d |
@whuber Of course, I could, but since I never used R I'm not able to fully understand your code ;)
|
|
Jan 9, 2020 at 15:15 | comment | added | whuber♦ | I'm sure you can write the C++ code that implements this very simple calculation! If not, SE is the place to ask about it. | |
Jan 9, 2020 at 15:11 | comment | added | 0xbadf00d | @whuber Thanks for your input, but I need it in C++. | |
Jan 9, 2020 at 14:06 | comment | added | whuber♦ |
In 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.
|
|
Jan 9, 2020 at 5:28 | comment | added | 0xbadf00d | @whuber I need the density for an importance sampling correction. I don't understand your suggestion. Do you say that I should sample $y$ as usual and then compute density as described in my first comment (where it is most probably sufficient to only take the first sumand $k=0$ for my choice of $\sigma$)? Or what do you mean by a "circular method"? How would that be different from what I've described in the question? | |
Jan 8, 2020 at 20:33 | comment | added | whuber♦ | I don't see why sampling wouldn't work as it always does. Just estimate the density using a circular method so that values near the endpoints $\{0,1\}$ are treated appropriately. Indeed, you may safely shift all values (modulo $1$) to make any single observation the new origin and treat the problem as estimating a density from a Normal sample. The chance of erring is far less than $10^{-100}.$ But why is there any need? You already know what distribution you are sampling from! | |
Jan 8, 2020 at 20:28 | comment | added | 0xbadf00d | @whuber Well, I guess you're right. Didn't thought about that (+1)! However, I guess I can't obtain the density simultaneously with sampling or is there a possibility? | |
Jan 8, 2020 at 20:20 | comment | added | whuber♦ | Then you can evaluate the density anywhere with a single term of the series! (At many points--more than about $0.05$ from the mean--you don't need any terms at all, because the density is practically zero there.) | |
Jan 8, 2020 at 20:18 | comment | added | 0xbadf00d | @whuber Thank you for your comment. The $\sigma$ I've got in mind is smaller than $1$, e.g. $\sigma=0.01$. | |
Jan 8, 2020 at 20:13 | comment | added | whuber♦ | When $\sigma$ is only a little larger than $1,$ for all practical computational purposes this density is uniform: see the last method at stats.stackexchange.com/a/117711/919. For smaller $\sigma,$ as @jbowman indicates, the sum converges very rapidly. It is a theta function; some software includes procedures to evaluate it (buried, for instance, in the KS test). | |
Jan 8, 2020 at 20:00 | comment | added | 0xbadf00d | @jbowman So, should I sum from $k=0,1,2,\ldots$ adding up $a_k:=\varphi_{\sigma^2}(y+k)$ and $b_k:=\varphi_{\sigma^2}(y-k)$ and stop once $a_k<\epsilon$ for some suitable $\epsilon$ (maybe $\epsilon=10^{-6}$?)? Or should I check $b_k$ as well? | |
Jan 8, 2020 at 16:56 | comment | added | jbowman | It's an infinite sum, but for $\sigma$ not much larger than $1$, it will converge pretty quickly. Consider $\sigma = 2$ and $y = 1/2$; the 10th term is $\sim 2.5\times 10^{-6}$, and subsequent terms decrease by more than a factor of $10$. With $\sigma = 1$, the sixth term is $\sim 10^{-7}$ and the seventh $\sim 3\times 10^{-10}$, for example. | |
Jan 8, 2020 at 16:46 | history | asked | 0xbadf00d | CC BY-SA 4.0 |