For context, I know at least basic calculus and what random variables are, but not much about doing calculations with random variables. I came up with a problem for myself where there are two points separated by a horizontal distance $d$. A ray extends from each point, one with angle $\alpha$ and the other with angle $\beta$.
The angles are random variables with a uniform distribution on the open interval $(0,\pi)$ The question is to find the probability that the two rays intersect and the average height of intersection, which I believe would be the expected value conditioned on the intersection actually happening.
The approach I have so far is to replace the rays with lines. I place point A at the origin of an xy-plane so that point B has coordinates $(d,0)$ For A or B, the line has to go through the point and have the right slope, so choosing the angle will define the line. The intersection of the two lines is a pair of random variables $(X,Y)$. In this case I'm assuming the intersection will exist since the intersection can also be below the two points. If it doesn't exist, that means the lines are parallel, which happens if $\alpha=\beta$. Letting $\theta=\alpha-\beta$, the probability of that is $$P(\alpha=\beta) = P(\alpha-\beta=0) = P(\theta=0) = 0$$
since $\theta$ is a continuous random variable. So I will assume that $(X,Y)$ always exists. The two original rays intersecting is the same event as these two lines intersecting above the x-axis, so the probability is $P(Y\gt0)$ and the average is $E(Y | Y\gt0)$
Now the slope of a line is related to the angle because $$\frac{\text{rise}}{\text{run}}=\frac{\text{opposite}}{\text{adjacent}}$$ $$\text{slope} = \tan(\theta)$$
Point A is the origin, so the equation of the line is $y=(\tan\alpha)x$ For point B, the slope is $\tan\beta$ and a known point is $(d,0)$ so $$y-y_1=m(x-x_1)$$ $$y-0=(\tan\beta)(x-d)$$ $$y=(\tan\beta)x-d\tan\beta$$ Solve both linear equations for x and set them equal to get $$\frac{y}{\tan\alpha}=\frac{y+d\tan\beta}{\tan\beta}$$ $$y\tan\beta=y\tan\alpha+d\tan\alpha\tan\beta$$ $$y\tan\beta-y\tan\alpha=d\tan\alpha\tan\beta$$ $$y(\tan\beta-\tan\alpha)=d\tan\alpha\tan\beta$$ So the random variable $Y$ is defined as $$Y=\frac{d\tan\alpha\tan\beta}{\tan\beta-\tan\alpha}$$ The value of $d$ is positive so $Y$ is positive if $$\frac{d\tan\alpha\tan\beta}{\tan\beta-\tan\alpha}\gt0$$ $$\frac{\tan\alpha\tan\beta}{\tan\beta-\tan\alpha}\gt0$$ $$\frac{\tan\alpha\tan\beta}{\tan\beta-\tan\alpha}+\frac{1}{\tan\beta-\tan\alpha}\gt\frac{1}{\tan\beta-\tan\alpha}$$ $$\frac{1+\tan\alpha\tan\beta}{\tan\beta-\tan\alpha}\gt\frac{1}{\tan\beta-\tan\alpha}$$ $$\left(\frac{\tan\beta-\tan\alpha}{1+\tan\alpha\tan\beta}\right)^{-1}\gt\frac{1}{\tan\beta-\tan\alpha}$$
$$\left(\tan(\beta-\alpha)\right)^{-1}\gt\frac{1}{\tan\beta-\tan\alpha}$$
$$\frac{1}{\tan(\beta-\alpha)}\gt\frac{1}{\tan\beta-\tan\alpha}$$
How do you calculate $P\left(\frac{1}{\tan(\beta-\alpha)}\gt\frac{1}{\tan\beta-\tan\alpha}\right)$ as well as $E(Y | Y\gt0)$?
There is an intrinsic symmetry to the question. In the case where we have replaced the rays by lines, there is always an intersection, either above or below the horizontal axis, except in the case where the lines are parallel, which occurs with probability $0$. Therefore, the probability of intersection of two rays is simply $1/2$.
Another way to see this is to observe that for each configuration of the two rays above the horizontal axis, draw a corresponding configuration in which the rays are drawn on the same lines through the two points, except in the opposite direction, so they are below the horizontal axis. Except for the parallel case, exactly one of these two configurations will intersect. Since these can be placed in one-to-one correspondence and both configurations are identically distributed in the space of elementary outcomes, the probability is $1/2$.
A third way to reason is to note that the rays intersect if and only if $\beta > \alpha$. This is because $\pi - \beta$ is the supplementary angle to $\beta$, and if the rays intersect, they form a triangle above the horizontal axis with interior angles $\alpha, \pi - \beta$, and a third angle $\gamma$ that must satisfy $$\alpha + (\pi - \beta) + \gamma = \pi.$$ Hence $\gamma > 0$ implies $\beta > \alpha$. It follows that the probability of this event is simply $$\Pr[\beta > \alpha] = 1 - ( \Pr[\alpha = \beta] + \Pr[\alpha > \beta] ) = 1 - \Pr[\alpha > \beta].$$ But $\alpha$ and $\beta$ are independent and identically distributed, so $\Pr[\alpha > \beta] = \Pr[\beta > \alpha]$, hence $\Pr[\beta > \alpha] = 1/2$.
The random height $H$ can be computed by noting that if $d$ is the separation distance, then $$\tan \alpha = \frac{H}{d_\alpha}, \quad \tan (\pi - \beta) = \frac{H}{d_\beta}, \quad d_\alpha+d_\beta = d.$$ Eliminating the auxiliary variables $d_\alpha, d_\beta$ yields $$H = \frac{d}{\cot \alpha - \cot \beta}.$$ Then we integrate for the expectation under the condition that $\pi > \beta > \alpha > 0$.
$$\operatorname{E}[H] = \frac{2}{\pi^2} \int_{\alpha = 0}^\pi \int_{\beta = \alpha}^\pi \frac{d}{\cot \alpha - \cot \beta} \, d\beta \, d\alpha.$$
However, this integral does not converge, meaning that the average height is infinite. And this makes intuitive sense, since the height will be very large when $\beta$ is just slightly greater than $\alpha$.