Simulation to estimate a conditional expectation Let X and Y be independent and identical exponential random variables with parameter $\theta>0$. Compute $P[X \leq x | X+Y]$ for $x\geq0$.
I tried to solve this theoretically here (https://math.stackexchange.com/questions/4508874/conditional-distribution-function-of-one-random-variable-given-the-sum-of-two) and I wanted to verify it through simulation as I'm waiting a response.
Any suggestion?

We could approach the problem using inverse transform sampling: generate random samples from the standard uniform distribution ($U$) and, given $X+Y$ that we specify, solve for $X$ and $Y$ for each $U$ using the hypothesized CDF. Then test whether $X$ and $Y$ are iid exponential variates.
Equivalently, we can reverse that approach by generating random $X$, $Y$ pairs, where the same exponential distribution is used within each pair. Then use the hypothesized CDF to transform them to $Z=\frac{X}{X+Y}$ (basically inverse transform sampling in reverse). Then simply test if $Z\sim U(0,1)$.
In R:
set.seed(94)
n <- 1e7L
X <- rexp(n)
Y <- rexp(n)
z <- X/(X + Y)
ks.test(z, "punif")
#> 
#>  One-sample Kolmogorov-Smirnov test
#> 
#> data:  z
#> D = 0.00029162, p-value = 0.3629
#> alternative hypothesis: two-sided

Check that the results hold while allowing the rate parameter to vary with each $X$, $Y$ pair:
theta <- runif(n)
X <- rexp(n, theta)
Y <- rexp(n, theta)
z <- X/(X + Y)
ks.test(z, "punif")
#> 
#>  One-sample Kolmogorov-Smirnov test
#> 
#> data:  z
#> D = 0.00037478, p-value = 0.1205
#> alternative hypothesis: two-sided

Or plot the ECDF:
set.seed(94)
n <- 1e6L
X <- rexp(n)
Y <- rexp(n)
plot(ecdf(X/(X + Y)))


theta <- runif(n)
X <- rexp(n, theta)
Y <- rexp(n, theta)
plot(ecdf(X/(X + Y)))


