A couple of weeks ago I hit a small math problem related to probabilistic and I thought it was trival (it took me a few hours to solve, though :p ). However I could not find a good stack exchange post or whatever that answers my problem, so I put it here for the sake of my future reference and possibly some people who happen to hit the same problem.
Note that the "short answer" itself really is short and trival, but the point of this post is the last section that describes the relationship between the "short" and the "long" answers.
Let the probability that a coin shows its head in a coin toss be x (0 < x < 1) and the expected number of heads after N tosses be M, compute x using N and M.
The expected number of heads for one toss is obvisouly x. Because the expected value of the sum of two independent probablistic variables is equal to the sum of the expected value of each probablistic variable (E[X + Y] = E[X] + E[Y]), the expected number of heads for N tosses is Nx.
Therefore, and .
Long Answer (kind of)
By definition, the expected number of heads M can be expressed using x and N as follows:
where is the probability that exactly n coins show their heads and defined as:
We can compute x from M and N by solving this equation for x..... but how??? (this is an N-th order equation of x!)
Both the short and the long answers say correct stuff, which means one thing:
And below is a proof:
where and . Note that . The term after is equal to 1 as shown below:
Let's Check Numerically
For those who may suspect the proof above, here are Ms calculated by the short and the long answers for N = 100 (there are small differences by numerical errors, but they are pretty much the same).
Here is the code used to generate the table above. Note that M_long(x) does not work for a large N due to overflow.
import scipy.special as sp N = 100 def M_short(x): return N * x def M_long(x): ans = 0 for n in range(1, N+1): ans += n * sp.comb(N, n) * pow(x, n) * pow(1 - x, N-n) return ans print("|x|M_short|M_long|") print("|-|-------|------|") for i in range(0, 25): x = i / 25 print("|", x, "|", M_short(x), "|" , M_long(x), "|")