1

Let $X$ be an $(-1,1)$-valued random variable and $D:=\operatorname\min(|X|,1-|X|)$. How can we compute $\operatorname E\left[D^2\right]$?

I have no good idea how I need to approach this. In my actual application $X=Y_1-Y_2$, where $Y_i=\iota Z_i$ for some $Z=(Z_1,Z_2)\sim\mathcal N((x,x),\Sigma)$ and $$\iota:\mathbb R\to[0,1)\;,\;\;\;y\mapsto y-\lfloor y\rfloor.$$ Here $x\in[0,1)$ and $\Sigma\in\mathbb R^{2\times 2}$ is positive. If $\sigma_i^2:=\Sigma_{ii}$, then obviously $Z_i\sim\mathcal N(x,\sigma_i^2)$.

But even in this special situation I don't know how to simplify $\operatorname E\left[D^2\right]$

Mittens
  • 39,145
0xbadf00d
  • 13,422
  • If $\mu_X$ I the law of $X$, you are looking at evaluating the integral $\int_{|x|\leq 1/2}|x|^2,\mu(dx)+\int_{|x|> 1/2}(1-|x|)^2,\mu(dx)$ – Mittens Dec 06 '22 at 15:56
  • @OliverDíaz I need an analytical expression for the expectation, since I want to maximize it depending on the choice of the variance of $Z$. – 0xbadf00d Dec 06 '22 at 15:58
  • You can still solve the whole think numerically by making things depends on variance of $Y$. then add two more lines of R code. Or solve the integrals in my previous comment. – Mittens Dec 06 '22 at 16:00
  • @OliverDíaz Maybe you can elaborate on your numerical approach, since I don't know how I would do this. Regarding the integral: It is clear to me that this is the expression we would like to simplify, but this is pretty hard (at least for me) in the special case of $Y_i=\iota Z_i$ I described in the question. Or am I missing something and you think it's easy? – 0xbadf00d Dec 06 '22 at 16:03
  • @OliverDíaz Yes, sorry! – 0xbadf00d Dec 06 '22 at 19:32
  • As you can see from running the code, if the variance of $X$ is large the expected value of interest gets close to $1/12$. For $\sigma<<\varepsilon$, the expected value of interest is also close to $0$ (this is not surprising as $\sigma\rightarrow0$ means that $X$ converges to $0$ in distribution. – Mittens Dec 06 '22 at 19:38

1 Answers1

1

Notice that $\min(|\{x\}-\{y\}|,1-|\{x\}-\{y\}|)=\min(\{x-y\},1-\{x-y\})$, where $\{x\}:=x-\lfloor x\rfloor$. Then, the expected value of interest is given by \begin{align} \mathbb{E}[\Big(\min(|\{Z_1\}-\{Z_2\}|,1-|\{Z_1\}-\{Z_2\}|\big)^2]&=\mathbb{E}[\big(\min(\{Z_1-Z_2\},1-\{Z_1-Z_2\}\big)^2]\\ &=\int\big(\min(\{x\},1-\{x\}\big)^2\,\mu(dx) \end{align} where $\mu$ is the distribution of $X'=Z_1-Z_2$

Since $Z=[Z_1\,Z_2]^\intercal$ is assumed to be normal with common mean, $X'=Z_1-Z_2$ is a normal with mean $0$ a some variance $\sigma^2>0$.

Here is a simple R code to simulate a situation like the one described by the OP. It can be used to get some insight into the problem.

### function f(x)=min(|x|,1-|x|) 
zfunc <- function(x){
  min(abs(x),1-abs(x))
}
zfunc <- Vectorize(zfunc,vectorize.args = "x")

Function that estimates mean of min^2([X],1-[X])

N sample size

sigma: variance ofsamples from normal distribution

Zmean <- function(N=3e5, sigma){ Xsamp1 <- rnorm(N, mean = 0, sd = sigma) Xsamp2 <- rnorm(N, mean = 0, sd = sigma) Xsamp1.floor <- Xsamp1 - floor(Xsamp1) Xsamp2.floor <- Xsamp2 - floor(Xsamp2) Xsamp.floor <- Xsamp1.floor - Xsamp2.floor Zsamp <-(zfunc(Xsamp.floor))^2 zmean <- mean(Zsamp) Zsd <- sqrt(var(Zsamp)) return(list(mean = zmean, sd = Zsd)) }

Example

sigma <- seq(.1,10, by = .01) Zmeans <- lapply(sigma, function(x){Zmean(sigma = x)}) z2 <- sapply(Zmeans,'[[',1) plot(sigma, z2, type = 'l')

The code of course can be improved to make the sample size $N$ more sensitive to the size of the variance $\sigma^2$.

The numerical experiments (using the R script above) suggest that as a function of $\sigma^2:=\operatorname{var}[X']$, $E_{\sigma^2}[(\min(|\{X'\}|,1-|\{X'\}|)^2]=E_{\sigma^2}[D^2]$ is monotone nondecreasing and seems to converge to a value around $0.0833$ as $\sigma^2\rightarrow\infty$. This can be explain by Fejer's theorem as follows. Let $f(x;\sigma)=\frac{1}{\sqrt{2\pi\sigma^2}}e^{-x^2/2\sigma^2}$ be the the density function of the Normal distribution with mean $0$ and variance $\sigma^2$. The expectation in the OP is of the form $$\int_{\mathbb{R}}f(x;\sigma^2)\big(\min(\{x\},1-\{x\}\big)^2\,dx=\int f(x;1)\big(\min(\{\sigma x\},1-\{\sigma x\}\big)^2\,dx$$ where $\{x\}=x-\lfloor x\rfloor$. As the function $x\mapsto \min(\{x\},1-\{x\})$ is $1$-periodic, we have that \begin{align} \lim_{\sigma\rightarrow\infty}\int f(x;1)\big(\min(\{\sigma x\},1-\{\sigma x\}\big)^2\,dx&=\left(\int^1_0\big(\min(\{x\},1-\{x\}\big)^2\,dx\right)\int_\mathbb{R} f(x;1)\,dx\\ &=\frac{1}{12}= 0.08\bar{3} \end{align}

On the other extreme, as $\sigma^2\rightarrow0$, $\mathbb{E}_{\sigma^2}[D^2]\rightarrow0$. This is not surprising since $X'$ converges to $0$ in distribution as $\sigma^2\rightarrow0$.

Mittens
  • 39,145
  • Thank you for your answer. I think it is really helpful. However, there is a slight problem which I still cannot resolve: You seem to assume that $X=\iota(\tilde Z)$ for some $\tilde Z\sim\mathcal N(x,\sigma^2)$, but I don't see why this is the case. The problem is that $X=\iota Z_1-\iota Z_2$ and we only know that $(Z_1,Z_2)\sim\mathcal N((x,x),\Sigma)$ and hence $Z_i\sim\mathcal N(x,\sigma_i^2)$. I don't know whether we can show (but I would be higly interested in that) $X=\iota(\tilde Z)$ for some $\tilde Z\sim\mathcal N(x,\sigma^2)$ and some $\sigma^2>0$. – 0xbadf00d Dec 06 '22 at 19:46
  • Without the letter knowledge, I only obtain that $$\operatorname E[X^2]=\int\lambda^{\otimes2}({\rm d}(z_1,z_2))\varphi_\Sigma(z_1-x,z_2-x)\min\left(|\iota(z_1)-\iota(z_2)|,1-|\iota(z_1)-\iota(z_2)|)\right)^2,$$ where $\lambda$ denotes the Lebesgue measure on $\mathcal B(\mathbb R)$ and $\varphi_\Sigma$ the density of $\mathcal N(0,\Sigma)$. – 0xbadf00d Dec 06 '22 at 20:28
  • That detail (I guess you mean $X=\iota(\tilde Z)$ for some $\tilde Z\sim\mathcal N(x,\sigma^2)$ and some $\sigma^2>0$) is actual the primary reason why I've asked that question. See my comment above; I'm not able to simplify this. So, I'd be really thankful if you could provide an answer to this. – 0xbadf00d Dec 06 '22 at 20:29
  • $Z_1-Z_2$ is normal and $\min(|{x}-{y}|,1-|{x}-{y}|)=\min(|{x-y},1-{x-y})$ – Mittens Dec 06 '22 at 20:31
  • I know that $Z_1-Z_2$ is normal, since $Z$ is normal. But the latter identity you're claiming in your comment is exactly what I'm failing to prove (which is why I've already asked a sepate question for that https://math.stackexchange.com/q/4591614/47771). – 0xbadf00d Dec 06 '22 at 20:33
  • Huh? If $x\in(-1,1)$, then we should have $\left|x\right|{(-1,:1)}=\min(|x|,1-|x|)$. So, $D$ (in this question) is equal to $\left|\iota(Z_1)-\iota(Z_2)\right|{(-1,:1)}$. – 0xbadf00d Dec 06 '22 at 20:48
  • Thank you very much. Your answer was of great help. Let me just ask you two more things: (a) I never heard of Fejer's theorem before. How did you applied it? Are you using a different version than the one shown on Wikipedia? I don't see how the version shown there could be applied here. – 0xbadf00d Dec 06 '22 at 22:34
  • (b) In our case, $\sigma^2=\Sigma_{11}+\Sigma_{22}-2\Sigma_{12}$. I would like to maximize $\operatorname E[D^2]$ with respect to $\Sigma_{12}$. From your answer we should need to choose $\Sigma_{12}$ as small as possible, since then $\sigma^2$ is maximized. Right? If so, how should we actually choose $\Sigma_{12}$? We need to choose it in a way such that $\Sigma$ is still positive definite. How do we ensure this? – 0xbadf00d Dec 06 '22 at 22:37
  • Should we compute the eigenvalues of $\Sigma$ (they need to be positive)? Or is this not a clever approach? At least if $\Sigma_{11}=\Sigma_{22}$, then the eigenvalues are $\Sigma_{11}\pm\Sigma_{12}$. – 0xbadf00d Dec 06 '22 at 22:40
  • I applied Fejer's lemma to decouple the rapidly oscillating function (and periodic) $\min({\alpha x}^2,(1-{\alpha x})^2))$ in the integral. I gave you a link to an old posting of mine where I also present a prove of the result. – Mittens Dec 06 '22 at 23:01
  • Let $\rho:=\frac{\operatorname{cov}(X_1,X_2)}{\sqrt{\operatorname{var}(X_1)\operatorname{var}(X_2)}}$ Then $\sigma^2=\operatorname{var}(Z_1-Z_2)=(\operatorname{var}(Z_1)+\operatorname{var}(Z_2))\Big(1-2\tfrac{\operatorname{var}(Z_1)\operatorname{var}(Z_2)}{\operatorname{var}(Z_1)+\operatorname{var}(Z_2)}\rho\Big)$. If $\operatorname{var}(Z_1)=\operatorname{var}(Z_2)=\sigma^2_1$, then $\sigma^2=2\sigma^2_1(1-\rho)$. From numerical experiments $E_{\sigma^2}D^2$ is monotone nondecreasing; so, $E[D^2]$ is largest when $\rho=0$ (independence) and smallest when $\rho=1$ ($Z_1=Z_2$ almost surely) – Mittens Dec 06 '22 at 23:21
  • Shouldn't it be $\sigma^2=2\sigma_1^2(1-\sigma_1^2\rho)$ in case $\operatorname{var}(Z_1)=\operatorname{var}(Z_2)=\sigma^2_1$? – 0xbadf00d Dec 07 '22 at 09:56
  • And isn't your conclusion wrong as well? We don't have $\rho\ge0$! So, the smallest value of $\rho$ should not be $\rho=0$ (independence), but a negative value. What we need to do is determining what the smallest (negative) value of $\rho$ is such that $\Sigma$ is still a valid covariance matrix. – 0xbadf00d Dec 07 '22 at 10:11
  • You are right. The expression for the variance of $X'$ should be $\sigma^2=2\sigma^2_1(1-\rho)$ where $\sigma^2_1$ is the common variance od $Z_1$ and $Z_2$. The largest value of $\sigma^2$ is attained at $\rho=-1$. – Mittens Dec 07 '22 at 14:23
  • While you wrote that I'm right, you still shown your previous expression for $\sigma^2$. If you insert $\sigma^2_1$ for $\operatorname{var}(Z_i)$ in $\sigma^2=\operatorname{var}(Z_1-Z_2)=(\operatorname{var}(Z_1)+\operatorname{var}(Z_2))\Big(1-2\tfrac{\operatorname{var}(Z_1)\operatorname{var}(Z_2)}{\operatorname{var}(Z_1)+\operatorname{var}(Z_2)}\rho\Big)$, this should be $2\sigma_1^2(1-\sigma^2_1\rho)$ ... – 0xbadf00d Dec 07 '22 at 15:20
  • The issue is that there should a square root in one factor. I see I made a mistake in my initial comment regarding the covariance ratio which got carried out throughout thereon. The right expression for the variance of $X'=Z_1-Z_2$ is $\sigma^2:=(\sigma^2_1+\sigma^2_2)\Big(1-2\frac{\sigma_1\sigma_2}{\sigma^2_1+\sigma^2_2}\rho\Big)$, where $\sigma^2_j$ is the variance of $Z_j$. When $\sigma_1=\sigma_2$, then $\sigma^2=2\sigma^2_1(1-\rho)$. – Mittens Dec 07 '22 at 16:30
  • Comments are not for extended discussion; this conversation has been moved to chat. – Xander Henderson Dec 07 '22 at 17:16