# Getting the same result from Integrate as Probability

I'm trying to solve a Baysian inference problem (although the details are not all that important for this question)

I define two probability distributions P and Q

pdf[N_, n_, p_][x_] := (1 + N) (1 - x)^(-n + N) x^n Binomial[N, n]
P = ProbabilityDistribution[pdf[N, n, p][x], {x, 0, 1}]
Q = ProbabilityDistribution[pdf[M, m, q][x], {x, 0, 1}]


Now Mathermatica is very happy to compute the $$Pr_{q\sim Q, p\sim P}[q>p]$$

Probability[q > p, {q \[Distributed] Q, p \[Distributed] P}]
(* (1 + M) (1 + N) Binomial[M, m] Binomial[N, n] Gamma[1 - m + M] Gamma[
1 + n] Gamma[
2 + m + n] HypergeometricPFQRegularized[{1 + n, 2 + m + n,
n - N}, {2 + n, 3 + M + n}, 1] *)


Side note I'm quite impressed it takes only .2s for this)

However if I try to compute this from a first principles standpoint i.e $$Pr_{q\sim Q, p\sim P}[q>p] = \int_{y>x} f_Q(y) f_P(x) dx dy = \int_{0}^1\int_{x}^1 f_Q(y) f_P(x) dy dx$$ with

Integrate[PDF[Q, y] PDF[P, x], {x, 0, 1}, {y, x, 1}]


I just get stuck waiting. I've also tried adding all assumptions but no luck

$Assumptions = {{m, n} \[Element] NonNegativeIntegers, {M, N} \[Element] PositiveIntegers, 0 < \[Alpha] < 1, M >= m, N >= n, 0 <= p <= 1, 0 <= q <= 1}  I'd like to understand where this big hypergeometric solution comes from as it's th result of a theorem I want to prove in my research so any hints would be helpful. I figured at least getting the integral result to be equal would give me a start in figuring out how to tackle that integral. Thanks ## 1 Answer Got it figured out, Mathematica just wants some assumptions about the integration variables and needs GenerateConditions->False: $Assumptions = {{m, n} \[Element]
NonNegativeIntegers, {M, N} \[Element] PositiveIntegers,
0 < \[Alpha] < 1, M >= m, N >= n, 0 <= p <= 1, 0 <= q <= 1,
0 < x < 1, 0 < y < 1}
Integrate[PDF[Q, y] PDF[P, x], {x, 0, 1}, {y, x, 1},
GenerateConditions -> False]

(* (Gamma[1 - m + M] Gamma[1 + n] -
Gamma[2 + M] Gamma[2 + m + n] Gamma[
2 + N] HypergeometricPFQRegularized[{1 + m, m - M,
2 + m + n}, {2 + m, 3 + m + N}, 1])/(
Gamma[1 - m + M] Gamma[1 + n]) *)

• You don't need the assumptions, just the GenerateConditions->False.
– mef
Jun 3 at 12:06