In the midst of my thesis I stumbled upon a nontrivial problem regarding probability density functions. I have two probability functions (known functional form) of (independent) variables $X\in\Omega_X$ and $Y\in\Omega_Y$, namely $P(X)$ and $P(Y)$.
The sets can be as $\Omega_X\in\mathbb{R}^+$, $\Omega_Y\in\mathbb{R}^+$, or $\Omega_X\in\mathbb{N}^+$, $\Omega_Y\in\mathbb{N}^+$ and are finite, for computational reasons. For simplicity I am now considering only the former case, where the $\Omega$ sets are in the reals.
Let $r\in(0,1)$ be a random number, I'd like to find the couple $(\hat{X},\hat{Y})$ such that: $$ \int_{\min\Omega_X}^\hat{X}\int_{\min\Omega_Y}^\hat{Y}P(X)P(Y)\,dYdX=r\cdot \int_{\Omega_X}\int_{\Omega_Y}P(X)P(Y)\,dYdX $$ where the RHS integral is meant all over the $\Omega_X\times\Omega_Y$ space.
The above relation is a "inverse" problem, since usually the limits of integration (LHS) are known, and the result for the RHS is the unknown. Moreover, it is derived from the cumulative probability density function, that is set equal to a generic number $r$: $$ \mathit{CPD}\,(\hat{X},\hat{Y})=\frac{\int_{\min\Omega_X}^\hat{X}\int_{\min\Omega_Y}^\hat{Y}P(X)P(Y)\,dYdX}{\int_{\Omega_X}\int_{\Omega_Y}P(X)P(Y)\,dYdX}=r $$ so if $\hat{X}=\max\Omega_X$ and $\hat{X}=\max\Omega_Y$, the LHS is unity.
I have proven that the function $\mathit{CPD}\,(X,Y)$ is injective, thus I believe only one solution can exist, but I have got no clue even where to start proving it, if it is even provable. I tried to solve it numerically, but I fell short finding any good algorithm for it.
After a while, I was able to solve it myself. I'm posting the answer for reference purposes for other users.
The above relation seeks the set $\hat{\Omega}$ such that the function assumes a definite constant value. This set is also called the level curves's set and it is usually a smooth $\mathbb{R}^2$ curve, which implies that there are $\infty^2$ values that satisfy the above equation.
If $\mathit{CPD}\,(X,Y)$ is differentiable, the gradient is perpendicular to the level curve for any point. We can evaluate it explicitly and follow the steepest descent/ascent direction until the level curve with value $r$ is found.