Should I have discrepancies in the mean of a discrete distribution when estimating it's PDF using Inversion sampling?

14 Views Asked by At

I've been trying to create the Inversion sampling method in R for the distribution $Y \sim X_1 + X_2$, where $X_1 \sim Bin(100, 0.3)$ and $X_2 \sim Bin(100, 0.7)$. I haven't used qbinom here due to the sum of binomials variance inequality, and have instead created the PDF, and calculated the CDF as the sum of these probabilities from 0 to x.

Finally, with the random sample of $U \sim Uniform(0,1)$, I calculate x as the sum of all values in the CDF less than u, plus 1, so that I'm taking the value of x which coincides with the CDF value greater than u.

I debugged the code, and the code is definitely running as expected, so my question is whether the upward rounding of x leads to discrepancies in the mean?