tsinsen-a1489 lucky Draw "mathematical expectation"

Source: Internet
Author: User

Jominda too God, in fact, has been very clear, I will push it again.

The title means that there are N boxes, no difference cast m ball, each box score is the number of balls in each box.

First question:

Suppose the ball is in box I, then? ans = (mi + 1) ^ 2-mi ^ 2--ans = 2mi + 1

Also take expectations-E (? i) = 2E (? mi) + 1

I this box has an MI ball (assuming that a T-ball has been cast) for the T * pi to substitute E (? i) = 2 * t * pi + 1

Special to general, for any i,i = the probability of the current selected i is pi, then E (?) = Sigma (pi * E (? i)), substituting, E (?) = Sigma (2 * t * pi ^ 2 + pi) = 1 + 2 * t * Sigma (pi ^ 2).

So for t = [0, m-1], sum, ans = sigma (1 + 2 * t * Sigma (pi ^ 2)), ans = m + M * (m-1) * Sigma (pi ^ 2).

  

Second question:

For a person, we consider whether his winning situation, define it as Ci,ci if 1 is winning, otherwise. The answer is E (Sigma (CI)) = Sigma (E (CI)).

E (CI) probability for a person to win, E (CI) = 1-(1-pi) ^ M.

1#include <bits/stdc++.h>2 #defineRep (I, A, b) for (int i = A; I <= b; i++)3 #defineDrep (I, A, b) for (int i = A; I >= b; i--)4 #defineREP (I, A, b) for (int i = A; I < b; i++)5 #defineMP Make_pair6 #definePB Push_back7 #defineCLR (x) memset (x, 0, sizeof (x))8 #defineXX First9 #defineyy secondTen using namespacestd; OnetypedefLong Longi64; Atypedef pair<int,int>PII; - Const intINF = ~0U>>1; - Consti64 INF = ~0ull >>1; the //******************************* - Const intMAXN =100005; - intC[MAXN]; - DoublePow (Double Base,intnum) { +     DoubleRET =1; -      while(num) { +         if(Num &1) RET *=Base; A         Base*=Base; atNum >>=1; -     } -     returnret; - } - intMain () { -     intN, M; inscanf"%d%d", &n, &m); -I64 sum (0); toRep (I,1, N) scanf ("%d", &c[i]), sum + =C[i]; +     DoubleANS1 (0); -     Static DoubleP[MAXN]; theRep (I,1, n) p[i] =1.0* C[i]/sum; *Rep (I,1, n) ans1 + = p[i] *P[i]; $Ans1 *=m;Panax NotoginsengAns1 *= M-1; -Ans1 + =m; theprintf"%.2lf\n", ans1); +     DoubleAns2 =N; ARep (I,1, n) ans2-= Pow (1.0-1.0*P[i], m); theprintf"%.2lf\n", ans2); +     return 0; -}
View Code

tsinsen-a1489 lucky Draw "mathematical expectation"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.