Marginal probability of beta distribution

The problem: Suppose you have 10 voters and 2 candidates. Each voter has a probability $p$ of voting for a Candidate 1, and a probability $1-p$ of voting for Candidate 2. What is the probability that exactly 6 voters will vote for Candidate 1, if $p$ is described by a Beta(3,3) function?

My thought process: I think I need to look for the marginal probability $P(X=6|n=10)$. I know that the beta function can be integrated as $30\int_0^1 x^2 (1-x)^2 dx$, but I'm not sure how I should go about solving this process. Could someone please get me started on the right path? Thank you!

• Here's a down and dirty method. Beta(3,3) has a mean of .50 A Binomial of 10C6 (.5)^10 = .205 – user104266 Feb 15 '17 at 5:31
• Start by fixing $p$ and finding the chance that exactly six voters choose Candidate 1. Then average over $p$. – whuber Feb 15 '17 at 23:24

You can frame this as a hierarchical model. In this case, $p$ has a Beta distribution. Then conditional on a particular value of $p$, $v$ - the number of votes for Candidate 1 - has a Binomial distribution with parameters 10 and $p$. This can be written as

$p \sim Beta(3, 3)$

$v | p \sim Binomial(10, p)$

First, find the joint density using the distributions given above. From the definition of conditional probability, we can write the joint as

$f_{v,p}(v,p) = P(v|p)P(p)$

Now integrate out $p$ to get the marginal of $v$

$f_v(v) = \int P(v|p)P(p) dp$

You can use this marginal distribution to calculate probabilities.

I really like hierarchical models because they let you express complex system in terms of more tractable components. For example, calculating the expected number of votes for candidate 1 is easy in this setting. Using the law of iterated expectation,

$E[v] = E[E[v|p]] = E[10p] = 10E[p] = 10(.5) = 5$