# Probability of a vector lying in an interval

Suppose we have a vector $\vec{v}$ with constant length that is equally likely to be pointing in any direction, specified by $\theta$ w.r.t the $x$ axis .

How can I compute the probability of the $x$ component of $\vec{v}$ lying in the range $v_{x}$ to $v_{x} + \mathop{dx}$

By working and looking online, I have been able to figure out the following:

Let $|v|$ denote the magnitude of the vector $v$. Then,

$v_{x}$ = $|v|cos(\theta)$

We have $P(v_{x} \leq u) = P(vcos(\theta) \leq u) = P(vcos(\theta) \leq u, \pi \leq \theta \leq 2\pi) + P(v\cos(\theta) \leq u, \pi \leq \theta \leq 2\pi)$.

Let the variable $w = u/v$. Then, our probability $P(v_{x} \leq u)$ equals

$P(\theta \geq arccos(w), 0 \leq \theta \leq \pi) + P(\theta \leq arccos(w), \pi \leq \theta \leq 2\pi) = \frac{|\pi - arccos(w)|}{\pi}$

However, I'm not sure how I'm supposed to proceed. I don't see how this relates, since it doesn't introduce $\mathop{dx}$? Could someone please help me from here?

A slightly less laborious way of writing this is: Let $\theta$ be a random variable describing the angle of the vector relative to the $x$ axis. Then we can write the vector in Cartesian coordinates as:

$$\vec{v} = |v|.(\cos \theta, \sin \theta)$$

Thus the probability of $v_x < \vec{v}_x < v_x + dx$ is simply the probability that $v_x < |v| \cos \theta < v_x + dx$.

If you want to, you can rewrite this as: $\arccos{\frac{v_x}{|v|}} < \theta < \arccos{\frac{v_x + dx}{|v|}}$. This is assuming that $\theta$ is between $0$ and $\pi$.

To proceed any further you need to integrate between those two bounds, and you need to know the distribution of $\theta$. Also this might be a question more suited to mathematics.stackexchange.com.

• That is simply the domain of $\theta$. A distribution provides a 'weighting' or 'likelihood' to every point of the domain. In your case, which is a continuous variable, you need to specify a probability density function. Sep 14 '18 at 7:57
• Very well, then you have a uniform distribution, and then the probability of $a < \theta < b$ is just $\frac{b-a}{2\pi}$. Note that you need to take into account that $\cos$ is symmetric around 0, so you only need to consider $0 < \theta < \pi$. Sep 14 '18 at 8:03
• Yes, those two cases are perfectly symmetric and give the same answer, that's why you only need to consider one. Sep 14 '18 at 8:13

So $\theta$ is uniformly distributed over $\theta\in[0, 2\pi]$, and

$$x = \cos{\theta}$$

so

$$\theta = \arccos{x}$$

with $x\in[-1,1]$

$$\frac{d\theta}{dx}\frac{\Delta x}{\Delta \theta} = \frac{1}{\sqrt{1-x^2}}\frac{2}{2\pi} =\frac{1}{\pi\sqrt{1-x^2}}$$

is the $x$ distribution.

Use python (matplotlib, numpy) to verify:

>>>theta = 2*pi*rand(10000000)

>>>x = linsapce(-1, 1, 1000)

>>>hist(cos(theta), bins=x, normed=True)

>>>plot(x[1:-1:1], 1/pow(1-x[1:-1:1]**2, 0.5)/pi)

So $\theta$ is uniformly distributed over $\theta\in[0, 2\pi]$, and

$$x = \cos{\theta}$$

so

$$\theta = \arccos{x}$$

with $x\in[-1,1]$

$$\frac{d\theta}{dx}\frac{\Delta x}{\Delta \theta} = \frac{1}{\sqrt{1-x^2}}\frac{2}{2\pi} =\frac{1}{\pi\sqrt{1-x^2}}$$

is the $x$ distribution.