# Mean and variance of $\tan(\mathcal{N}(\mu,\,\sigma^{2}))$

How could we find the mean and variance of $$\tan(\theta )$$ if $$\theta \sim \mathcal{N}(\mu,\,\sigma^{2})$$?

• Do you mean arctangent? The discontinuities will probability make non-real or non-existent solutions. Commented May 15, 2019 at 14:41
• @AdamO You are right. I tried with monte carlo, but I need to satisfye myself wirth some mathematical idea. May be with Taylor expansion . Commented May 15, 2019 at 14:48
• @KitterCatter: more precisely, the mean should be $\text{tan}\mu$. (Can we assume that $\mu$ is not a singularity of the tangent?) Commented May 15, 2019 at 15:04
• @StephanKolassa As per my idea if $\theta$ is small then value of $\tan(\theta)$ is $\theta$. Can we apply same things here? $$\tan( \mathcal{N}(\mu,\,\sigma^{2}))\, \approx \mathcal{N}(\mu,\,\sigma^{2})\,.$$ Commented May 15, 2019 at 15:15
• @StephanKolassa not quite. $E[f(X)] \ne f(E[X])$ in general because of Jensen's inequality. Commented May 15, 2019 at 15:22

The mean is not defined and the variance is infinite.

To see why this is, we have to analyze the integrals a little indirectly, because there are no formulas available. We will thereby obtain a more general result: namely,

When $$X$$ is a random variable whose distribution has a density $$f$$ that is positive and continuous in a neighborhood of any one of the numbers $$(k+1/2)\pi$$ (where $$k$$ is any integer), then $$E[\tan(X)]$$ is undefined and $$E[\tan(x)^2]$$ is infinite.

The very form of this statement exposes the essential idea: the tangent function grows so large so quickly near its poles at the values $$(k+1/2)\pi$$ that $$\tan(X)$$ cannot have an expectation unless $$X$$ has vanishingly small probability of being near any of those poles.

When $$X$$ has a distribution with density $$f,$$ the expectation of $$\tan(X)^j$$ (for any power $$j=0, 1, 2, \ldots$$) is

$$E[\tan(X)] = \int_\mathbb{R} \tan(x)^j f(x) \mathrm{d}x\tag{*}$$

Let's begin with the fact that $$\tan$$ has poles at the values $$\pi/2 + k\pi$$ for all integers $$k.$$ Thus, if this expectation $$(*)$$ exists, it can be broken into integrals of width $$\pi$$ spanning each successive pairs of poles. Between one pole and the other the tangent function rises from $$-\infty$$ to $$\infty,$$ crossing zero halfway through. Let's therefore further break such integrals into a left and right half. The rseulting integrals are of the form

$$I_{-}(f,j,k) = \int_{(k-1/2)\pi}^{k\pi} \tan(x)^j f(x) \mathrm{d}x$$

at the left, where $$\tan(x)\le 0,$$ and

$$I_{+}(f,j,k) = \int_{k\pi}^{(k+1/2)\pi} \tan(x)^j f(x) \mathrm{d}x$$

at the right, where $$\tan(x)\ge 0.$$

Assuming $$f$$ is continuous--which it is for all Normal distributions--we may interpret these as Riemann integrals. By definition, when the integrand might grow infinite at the endpoints, the Riemann integral is obtained by taking limits. For instance, the right integral is defined as

$$I_{+}(f,j,k) = \lim_{\epsilon\to 0^{+}} \int_{k\pi}^{(k+1/2)\pi-\epsilon} \tan(x)^j f(x) \mathrm{d}x.$$

Let's consider the case $$j=1.$$ Fix $$k$$ and note (just to make the analysis a little simpler looking) that

$$\int_{k\pi}^{(k+1/2)\pi-\epsilon} \tan(x) f(x) \mathrm{d}x = \int_{0}^{\pi/2-\epsilon} \tan(x) f(x-k\pi) \mathrm{d}x = \int_{0}^{\pi/2-\epsilon} \tan(x) g_k(x) \mathrm{d}x$$

where $$g_k(x)=f(x-k\pi)$$ is still a continuous function.

This figure depicts the setup: the graph of $$\tan$$ in blue, the density function $$g$$ filled in red, and their product--the thing we are integrating to find part of the expectation--filled in gold near the pole at $$\pi/2.$$ The analysis will underestimate both the upper gold area (the $$I_{+}$$ part) and lower gold area (the $$I_{-}$$ part) by showing the size of each exceeds some small multiple of the area bounded by the blue curve.

Indeed, $$g$$ is strictly positive (because the Normal density $$f$$ is never zero). Thus, for any given $$\epsilon \gt 0,$$ $$g_k$$ attains a positive minimum value $$g_{k,0}$$ on the interval $$[0, \pi/2].$$ Consequently

$$I_{+}(f,1,k) \ge g_{k,0}\int_{0}^{\pi/2-\epsilon} \tan(x) \mathrm{d}x \gt 0.\tag{**}$$

That got rid of the complicated factor $$g(x),$$ leaving an easy analysis,

$$\int_{0}^{\pi/2-\epsilon} \tan(x) \mathrm{d}x= -\log \cos(x)\vert_0^{\pi/2-\epsilon} = -\log\sin(\epsilon).$$

This diverges as $$\epsilon \to 0^{+}.$$ By virtue of the inequality $$(**),$$ $$I_{+}(f,1,k)$$ diverges for all $$k.$$

The same analysis applies to $$I_{-}(f,1,k),$$ which diverges (to $$-\infty$$). Consequently, $$E[\tan(X)]$$ is undefined because it's effectively an infinite sum of terms alternately diverging to $$\infty$$ and $$-\infty.$$

The power-mean inequality (or, if you like, a comparable analysis for the case $$j=2$$) shows that all the integrals summing to $$E[\tan(X)^2]$$ diverge to $$+\infty,$$ which means $$E[\tan(X)^2]$$ diverges to $$+\infty:$$ it is infinite. This implies the variance is infinite.

• Very nice indeed, and fast! Commented May 15, 2019 at 15:52
• @Aksakal That thought had occurred to me, too. However, there are two errors in it. First, what matters is not the parity of $\tan$, but the parity of $\tan(x)f(x).$ Unless $\mu$ is an integral multiple of $\pi,$ that product is not an odd function (at least for Normal PDFs $f$). The second error is that not all odd functions have zero integrals: you are perhaps thinking of something like the Cauchy principal part of the integral. Those are two of the reasons I have used a somewhat higher level of rigor than usual in answering an elementary-looking question.
– whuber
Commented May 15, 2019 at 17:56
• @whuber, yes Cauchy PV is zero Commented May 15, 2019 at 17:56
• @whuber, I see your point now, I was wrong, forgot about $\mu$ Commented May 15, 2019 at 18:06
• I'm having a hard time seeing how one would make sense of such a claim: $\mu$ and $\sigma$ represent numbers. There's no issue of being defined or not.
– whuber
Commented May 22, 2019 at 11:28