A shortcut to get the result from integration of
(q^c) * ((1-q)^d)
over the domain of q from 0 to 1 is simply computing the value of
c! / ((d+1)*(d+2)*...*(d+c+1)),
where c and d are constants in both formulas.
This is useful when a Bernoulli parameter q has a Beta prior distribution, and we need to find its posterior given observed Bernoulli trials. The posterior distribution of q is in the following form:
I * (q^c) * ((1-q)^d),
where I is the value computed from the above integration.
An even simpler but less intuitive way to get the posterior distribution is to recognize that the posterior is also a Beta distribution. Assume the prior Beta distribution has parameters a and b, that is to say
q ~ Beta(a, b),
and we observe n Bernoulli trials with x successes. The parameters of the posterior distribution, denoted by a_new and b_new can be obtained from the following formulas:
a_new = a + x
b_new = b + n
Therefore, q has a posterior distribution of
Beta(a_new, b_new),
and its mean is given by
a_new / (a_new + b_new).