Number theory----probability, expectation

Source: Internet
Author: User


In recent years, the ACM contest, the mathematical expectations of the problem often involves, in the past also often let oneself feel very headache, recently suddenly enlightened, mastered the basic analysis method, hope to everyone helpful. The writing is shallow, may be mathematically not rigorous, only for understanding.

First, look at what the basic formula is expected to be.

For the discrete random variable x, the probability is P, there is

For random variables A, B, there are

The second is the protagonist of today, and he shows that expectations are linear in nature, and simple to understand is to expect to be based on relationships, simple operations (less rigorous understanding). This solves an expectation problem and transforms it into a solution to another desired problem, which ultimately translates into a known expectation.

For the simplest example, see figure below.

Suppose that there is a person at node 1th, every minute he will wildest randomly to a node or stay in situ, ask him to go to the number 4th node requires an average of several minutes.

This is a simple expectation problem, and we use EI (i=1,2,3,4) to represent the mathematical expectation from the I node to the number 4th node. According to test instructions, the number 1th node has

e1= (1/3) *e1+ (1/3) *e2+ (1/3) *e3+1①

It means he can go to 2 or 3 or 1 in the next minute, each probability is 1/3, attention is the next minute, so add 1.

Similarly, we can also list the node 2,3

E2= (1/3) *e1+ (1/3) *e2+ (1/3) *e4+1②

e3= (1/3) *e1+ (1/3) *e3+ (1/3) *e4+1③

How much does that E4 equal? Obviously E4=0④, because he's going to be 4.

So the above 1234 is actually composed of a set of equations, the solution equations can be derived E1. , with Gaussian elimination, the complexity is O (n^3)

From the above example, we can summarize how to solve the expected class problem, according to test instructions, expressed the expectation of each state (the ei,1234 of the above example), according to the probability formula, lists the equation between the expectations, the solution equation can be.

Below see how to solve a problem with the above ideas (poj2096)

See annex 1 for the original question.

Test instructions Brief: a person employed by a company to find out a software bugs and subcomponents, the software has a total of n bugs and S subcomponents, each time he can randomly find 1 bugs and a subcomponent, Ask him to find all the bugs and subcomponents's expected number of times.

We use E (i,j) to indicate that he found the I bugs and J subcomponents, and the desired number of times to find the n bugs and S subcomponents, which required E (0,0), and E (n,s) = 0, for any e (i,j), 1 times to find 4 cases, found no new bugs and subcomponents, found a new bug, found a new subcomponent, and found a new bug and subcomponent, using the probability formula can be:

E (i,j) =1+ (I*J/N/S) *e (i,j) + (i* (s-j)/n/s) e (i,j+1) +

((n-i) *j/n/s) *e (i+1,j) + (n-i) * (s-j)/n/s*e (i+1,j+1);

This allows all E (i,j) to be solved according to the boundary, note because when we find n bugs and S subcomponents it ends, to i>n| | J>s is not a solution, it is not expected to be 0. (Mathematically common problems, 0 and non-existent differences)

Is this question also to use Gauss elimination yuan. The complexity of the words is O (n^3) with Gaussian elimination, and the 10^18 is not solvable at all.

But in fact, pay attention to the equation, when we want to solve E (I,J) will need E (i+1,j), E (i,j+1), E (i+1,j+1), at the beginning of the known E (n,s), that is, as long as we from the high to the low one by one to solve the i,j can be. You can solve all the E (i,j) complexity according to the recursive type O (n), 10^6, perfect solution. See annex 2 for procedures

From the above problem, we once again see the idea of solving the expected problem, and the use of recursion to solve the problem, in fact, the reason for recursion, when we consider each state as a node, the probability relationship for the forward edge, we can see that the problem of recursion is actually this diagram is non-ring. The problem that has to be solved with equations is actually the existence of rings .... And I would also like to point out that the use of Gaussian elimination, to pay attention to the problem of error, it is best to bashi the appropriate increase, to avoid the solution of decimals, otherwise the error is too large, the estimate will also be card problem.

-----------------------------------------------------------------

Easy to get started: Click the Open link to open the link

Summary of the Great God: Click to open the link zerolock

My topic: Click the Open link

2015.5.11 Update

When the transfer equation is obtained, how to break the ring is the key.

When each dimensional is associated with an unknown, iterate two times to Eg:hdu 4089

When there is more than one, it is necessary to use the Gaussian elimination element

===================================================

The problem of probability has been done in the previous period.

1, a=a+b+c ABC is three kinds of situation, then P (A) =a*p (a-> event) +b*p (b-> event) +c*p (C-> event);
The A-> event means that the event in a case is the thought of the full probability formula.
2, must pay attention to each step will not appear in the denominator of 0, and pre-processing time for some special circumstances cause their own formula will appear in the denominator of 0 of the platoon removed


First, the expectation

The problem of solving expectations is not understood at first. I did a lot of things later.

Example: (have put back)

In 5 products have 4 pieces of genuine, 1 pieces of defective, from any 2 pieces, which contain the number of genuine numbers for the random variable ξ, then ξ 's mathematical expectation eξ is 1.6

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.