#"Name"#
#X = " number of tosses for one person until he gets H"#
#"Then we have"#
#P(X=0) = 0#
#P(X=1) = 1/2#
#P(X=2) = (1/2)^2#
#...#
#P(X=n) = (1/2)^n#
#=> E(X) = 1/2*1 + (1/4)*2 + (1/8)*3 + ...#
#= sum_{n=1}^{n=oo} n*(1/2)^n#
#"Define"#
#f(a) = sum_{n=1}^{n=oo} n*a^n#
#= a * sum_{n=1}^{n=oo} n*a^(n-1)#
#= a * sum_{n=1}^{n=oo} (d/{da}) a^n#
#= a * (d/{da}) sum_{n=1}^{n=oo} a^n#
#= a * (d/{da}) ((1/(1-a)) - 1)#
#= a / (1-a)^2#
#=> f(1/2) = (1/2)/(1/4) = 2#
#=> E(X) = 2#
#"We have on average 5.5 persons tossing, so"#
#E(Y) = 5.5 * 2 = 11#
#"The variance for one person is"#
#"var = "E(X^2) - (E(X))^2#
#E(X^2) = sum_{n=1}^{n=oo} n^2*a^n" (with a = 1/2)"#
#= a^2 sum_{n=1}^{n=oo} n*(n-1)*a^(n-2) + a sum_{n=1}^{n=oo} n*a^(n-1)#
#= a^2 (d^2/{da^2}) (1/(1-a)) + a (d/{da}) (1/(1-a))#
#= 2 a^2 / (1-a)^3 + a/(1-a)^2#
#a = 1/2 => E(X^2) = 4 + 2 = 6#
#=>" var = "6 - 2^2 = 2#
#"Now the total variance for the experiment is the sum of the"#
#"variances because the individual tosses are independent."#
#"For a weighed sum, we have"#
#Var(sum a_i X_i) = sum a_i^2 Var(X_i)#
#=> " Variance = "(1/10)(2 + 2*2 + 3*2 + ... +10*2)*2^2#
#= (8/10)(1 + 2 + 3 + .. + 10)#
#= ((11*10)/2)*4/5#
#= 44#
#"So we don't need the long tedious calculation of E(Y²)"#
#"that goes as follows :"#
#P(Y=1) = P(x=1) P(X=1) = (1/10)(1/2) = 1/20#
#P(Y=2) = P(x=1) P(X=2) + P(x=2) P(X=1)^2 = (1/10)(1/4)+(1/10)(1/2)^2 = 1/20#
#P(Y=3) = P(x=1) P(X=3) + 2 P(x=2) P(X=1) P(X=2) + P(x=3) P(X=1)^3#
#= (1/10)(1/2)^3+(1/10)2(1/2)(1/4)+(1/10)(1/2)^3#
#= (1/10)(1/8 + 1/4 + 1/8) = 1/20#
#P(Y=4) = (1/10)((1/2)^4+(1/4)^2+2(1/2)(1/8)+3(1/2)^2(1/4)+(1/2)^4)#
#= (1/10)(1/16+1/16+1/8+3/16+1/16)#
#= 1/20#
#"In general we have"#
#"m persons "=> X_1+X_2+...+X_m = Y#
#"So we must search the number of ways to obtain Y as sum"#
#"of m integers > 0."#
#"This is a stars and bars problem."#
#"We have to divide Y stars in m groups by m-1 bars."#
#"Each group must have at least one star so we begin by giving"#
#"each group one star, so there are Y-m remaining stars."#
#=> C(Y-m+m-1,m-1) = C(Y-1, m-1) " combinations"#
#"For each combination, the probability is "(1/2)^Y.#
#=> P(Y=k) = ((1/2)^k/10) (C(k-1,0)+C(k-1,1) + ... + C(k-1,9))#
#"(we define C(k, i) = 0 if k < i)"#
#=> P(Y=k) = 1/20, " if " k <= 10#
#"(because the sum of all C(k,i) is "2^k")"#
#=> P(Y=11) = 1/20 - (1/2)^11/10#
#...#
#=> E(Y^2) = sum k^2 P(Y=k)#
#= sum_{k=1}^{k=10} k^2/20 + sum_{k=11}^{k=oo} k^2 P(Y=k)#
#= 19.25 + sum_{k=11}^{k=oo} k^2 P(Y=k)#
#= 19.25 + (1/10) (sum k^2*(1/2)^k*(1+k-1+((k-1)(k-2))/2+....))#
#"So we have 10 combination terms that need to be calculated."#
#"That is a lot of math and few probability, i leave it here."#