Expected Value of Binary Numbers A 10-digit binary number with four $1$s are chosen at random. What is its expected value?
Here is what I thought to do: There are $_{10}C_4$ possible digits that could be filled with $1$. Since there are $10$ digits, that means that each digit equals $1$ in $21$ different ways. Since, the sum of $2^1+2^2+\cdots +2^9= 2^{10}-1$, we can say that the sum of all possible values is $21\cdot (2^{10}-1)$. If we divide this by the number of possible number combinations $210$, we should get the answer. However, this is incorrect. Where did I go wrong?
 A: When you say there are $_{10}C_4=210$ strings with four $1$s and six $0$s, there are $840\ 1$'s spread among the $10$ digits, so $84\ 1$'s in each column.  The sum is then $84\cdot (2^{10}-1)$.  You lost the factor $4$ from the number of $1$'s in each number.  This assumes leading $0$s are allowed in your $10$ digit numbers.
A: The definition of expected value is as follows:
$$E(x)=\sum xp(x)$$, where $p(x)$ is the probability of $x$.
Here we add all the four bit numbers and divide it by the total number of four bit numbers.
So, essentially we will have the sum as $[2^0N(2^0)+2^1N(2^1)+2^2N(2^2)+......+2^9N(2^9)]/210$ ,where $N(x)$ means number of $x$ in the sum. $N(2^0)= $$^9C_3=N(2^1)=N(2^2)=......=N(2^9)$
So the answer is $$^9C_3\times1023/210$$
A: This is too long for a comment but might be interesting.
Here is a Mathematica code for the general problem of n digits and k 1's which also reveals the structure of the problem. It consists of four commands with respective examples:
(1) The array a(n,k) lists all pattern of 1's for n positions and k 1's
a[n_, k_] := Permutations[Join[Array[0 &, n - k], Array[1 &, k]]]

In[175]:= a[3, 2]
Out[175]= {{0, 1, 1}, {1, 0, 1}, {1, 1, 0}}
(2) The vector of powers of 2
v[n_] := Table[2^k, {k, 0, n - 1}] // Reverse

In[188]:= v[3]
Out[188]= {4, 2, 1}
(3) All possible numbers corresponding to the binary patterns are given by the scalar products of the power vector with the patterns
d[n_, k_] := Dot[v[n], #] & /@ a[n, k]

In[180]:= d[3, 2]
Out[180]= {3, 5, 6}
(4) And the mean of these numbers
m[n_, k_] := Mean[d[n, k]]

In[182]:= m[3, 2]
Out[182]= 14/3
In the concrete case we have
In[186]:= m[10, 4]
Out[186]= 2046/5
