# Probability of a random variable that represents a sum

The top students in a large high school graduation class are ranked from $1$ (best) to $10$ (tenth best). Assume that each rank is equally likely to be assigned to a male student or a female student. Let $X$ equal the sum of the ranks (from $1$ to $10$) that are assigned to female students, that is if all of the top $10$ students are girls, $X=1+2+3+...+10=55$. Provide the probability function on the sample space.

I believe that the total possible rankings is $2^{10} = 1024$, and I think that $P(X=k)$ is given by the ratio of (ways to get a sum $k$ of ranks assigned to females)/(all possible arrangements). I do not know how to represent the numerator as some type of function.

• Thank you, Leucippus, for the edit. – Brian Wynne Sep 15 '18 at 1:46
• Are you looking for a closed form formula or just the numbers in this specific case? – pepster Sep 15 '18 at 2:40

Here is a recursive Python function to compute the number of ways to get the sum total using 1,2,...,k

def f(total, k) :
""" Number of ways to obtain 'total' as a sum of uniqe integers from 1..k """
if total < 0 or k <= 0:
return 0
if 0 <= total <= 1:
return 1

if k > total:
k = total

return f(total, k-1) + f(total-k, k-1)


so $P(X=k) = \frac{f(k,n)}{2^n}$ ($n=10$ in your case). This kind of formula can be a good first step to validate any proposed closed form formulas.

• This was most helpful, pepster, thank you. – Brian Wynne Sep 17 '18 at 1:30