# Help in Obtain Desired Expected Value

Can anyone tell me the approach of the third problem( Obtain Desired Expected Value ) of Chennai Onsite . Link of problem

First of all there are three corner cases that you must consider.

1. If all the numbers are less than E. In this case, no matter what values you assign, their expected value will always be less than E.
2. If all the numbers are greater than E. In this case, the expected value will always be greater than E.
3. There is one number that is equal to E. In this case, set the corresponding p_i to 1.

In all other cases, there is at least one number less than and one number greater than ‘E’. Lets take any two such numbers, let the one less than ‘E’ be ‘A’ and the one greater than ‘E’ be ‘B’. Initially assign p=1 to ‘A’ and p=0 to ‘B’ (and p=0 to all other numbers). The expected value will be A. Now, if you were to reduce the value for A by some amount ‘x’ and increase the value for B by the same amount, what will the new expected value be ? it will be A * (1-x) + B * x. ie., the expected value increased by (B-A) * x.

So, by varying ‘x’ you can any real number in the range [A,B] as the expected value. Now, since you want it to be E, you need to increase it by E-A, ie (B-A) * x =(E - A), so x = (E-A)/(B-A). This will be the p value for B, and the p value for A will be 1 minus this value. Handle the case n=1 separately.

2 Likes

thanks a lot @hemanth_1 ,now i got this 1 Like

its incredibly instructive site.This is an edifying site by which I have that data which I genuinely expected to get.
resume writing services in india