Bijections Galore

Ram has 2018 coins.

The 1 st 1^\text{st} coin has a 1 2 \frac{1}{2} chance of flipping heads, the 2 nd 2^\text{nd} coin has a 1 3 \frac{1}{3} chance of flipping heads, the 3 rd 3^\text{rd} coin has a 1 5 \frac{1}{5} chance of flipping heads, continuing such that the k th k^\text{th} coin has a 1 p ( k ) \frac{1}{p(k)} chance of flipping heads, where p ( k ) p(k) is the k th k^\text{th} prime number.

Ram flips each of his coins once.

What is the probability that Ram flips an even number of heads ?

0.5 Less than 0.5 Greater than 0.5

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

8 solutions

Ankit Agarwal
May 21, 2018

Solution 1 The key to this problem is to recognize that the probability of flipping and even number of heads and the probability of flipping an odd number of heads depends only on the existence of a singular fair coin! To see this, consider any possible sequence of flips. (eg. HTHTTTTHHHTHTHTHTTTH...).

We can make a bijection to an equally likely string TTHTTTTHHHTHTHTHTTTH... where the first head is flipped to a tail and the rest of the string remains the same. These two strings are equally likely since the first coin, has a probability 1 2 \frac{1}{2} of flipping heads or tails! Since the parity of even heads must flip with a single coin change, we have found a one-to-one correspondence between strings that flip an even number of heads and strings that flip and an odd number of heads. So the answer is simply 1 2 \frac{1}{2}

Solution 2 Another way to do this problem, and similar problems without the use of fair coins is to use something known as a generating function. This is fairly technical and frankly, overpowered way to approach this problem, but it helps give insight into problems that are similar. So I am going to do something a bit strange, but after a bit of explanation, it might come to light as to why it works. Let p k p_k be the probability that the k th k^{\text{th}} coin flips heads. For each the k th k^{\text{th}} coin, I will associate the binomial x p k + ( 1 p k ) x \cdot p_k + (1 - p_k) to it. So for instance I will associate the binomial x 2 + 1 2 \frac{x}{2} + \frac{1}{2} to the first coin. Then, consider the polynomial formed by product of all the binomials for all the coins below:

P ( x ) = k = 1 2018 ( x p k + ( 1 p k ) ) P(x) = \prod_{k =1}^{2018} (x \cdot p_k + (1 - p_k))

Amazing fact : The coefficient of the x i th x^{i\text{th}} term in P ( x ) P(x) is the probability that Ram flips i i heads. See if you can convince yourself as to why and check out this wiki: generating functions .

If we plug in 1 for x x , each individual term in the product collapses to 1 and our answer evaluates to 1. This is also equal to the sum of all the coefficients of the expanded polynomial. However, if we plug in -1, all of the odd terms in the polynomial expansion of P ( x ) P(x) will become the negative value of their coefficient and all the even numbers will stay the same. Therefore, if we add the two values P ( 1 ) P(1) and P ( 1 ) P(-1) we will get twice the sum of even terms' coefficients, which is twice the probability that we flip an even number of heads! An example is shown below:

Example If we had 3 coins with probability 1 2 \frac{1}{2} , 1 3 \frac{1}{3} , and 1 5 \frac{1}{5} respectively. Then, P ( x ) P(x) is:

( x 2 + 1 2 ) ( x 3 + 2 3 ) ( x 5 + 4 5 ) = x 3 30 + 7 x 2 30 + 7 x 15 + 4 15 . (\frac{x}{2} + \frac{1}{2})(\frac{x}{3} + \frac{2}{3})(\frac{x}{5} + \frac{4}{5}) = \frac{x^3}{30} + \frac{7 x^2}{30} + \frac{7x}{15} + \frac{4}{15}.

P ( 1 ) = 1 = 1 30 + 7 30 + 7 15 + 4 15 P(1) = 1 = \frac{1}{30} + \frac{7}{30} + \frac{7}{15} + \frac{4}{15} and P ( 1 ) = 1 30 + 7 30 + 7 15 + 4 15 P(-1) = \frac{-1}{30} + \frac{7}{30} + \frac{-7}{15} + \frac{4}{15} . If we add them, the terms corresponding to an odd power of x x cancel and we are left with P ( 1 ) + P ( 1 ) = 2 ( 7 30 + 4 15 ) P(1) + P(-1) = 2 \cdot (\frac{7}{30} + \frac{4}{15}) , which is twice the probability we flip an even number of heads (terms that correspond to x 2 x^2 and x 0 x^0 ).

Now that we are done with the example, we calculate the probability of flipping an even number of heads as P ( 1 ) + P ( 1 ) 2 = 1 + P ( 1 ) 2 \frac{P(1) + P(-1)}{2} = \frac{1 + P(-1)}{2} . Going back to the product version of our function P P , we see that it k = 1 2018 ( 1 p k + ( 1 p k ) ) = k = 1 2018 ( 1 2 p k ) \prod_{k = 1}^{2018} (-1 \cdot p_k + (1 - p_k)) = \prod_{k = 1}^{2018} (1 - 2 \cdot p_k) . Here is the punchline: since the probability of flipping the first coin is 1 2 \frac{1}{2} , this product goes to 0, and our formula yields 1 2 \frac{1}{2} .

What is interesting about this formula and the product that we developed for P ( 1 ) P(-1) is that it reveals something deep about these problems in general. The generating function was only up to the value 2018 because we only had 2018 coins. Suppose we made the number of coins arbitrary (with a value n n ). In this case, our generating function would be:

P ( x ) = k = 1 n ( x p k + ( 1 p k ) ) P(x) = \prod_{k =1}^{n} (x \cdot p_k + (1 - p_k))

Amazing Fact 2: As long as the probability of flipping heads is between 0 and 1 for each coin, each term in our product formula for P ( 1 ) = k = 1 n ( 1 2 p k ) P(-1) = \prod_{k = 1}^{n} (1 - 2 \cdot p_k) would be between -1 and 1, which means that we are continually multiplying by a number whose absolute value is less than 1. This means that this product gets continually closer to 0 as this number as n n \to \infty even if we guarantee not to include any fair coins! So, as the number of coins increases, the probability tends towards 1 2 \frac{1}{2} .

Agreed. Consider all the flips except the first which is 50/50. If the total heads at this point is an even number then the odds of the flip is 50% heads 50% tails thus making the overall outcome 50%. The same is true if the total number of heads is odd.

Norman Pitts - 3 years ago

Nice. I actually missed this feature, found the formula for an arbitrary number of coins (it's actually a nice concise formula), and then when plugging in known values, I forgot about the fair coin. Oops!

Brian Moehring - 3 years ago

I didn't completely understand your first solution

Why only a fair coin is decisive? On the other hand if I consider answer as 1/2 I got another inference while trying to extract the answer That is if I consider any arbitrary coin the odds of flipping heads be x Let the odds that rest of the coins flipped even numbers of heads be y Then odds of getting even number of heads is (1-x)y+x(1-y)=y-xy+x-xy =x+y-2xy If the required probability is again y It infers that odds of flipping even number of heads is independent of coins even for finite . I agree it tends to 1/2 for infinitely many coins as even taking a coin out leaves with infinitely many again But for 2018 coins if you say it is 1/2 it follows same for 2017 2016 and so on ultimately for 2 Can you qualitatively explain the independency of coins?

madhav srirangan - 3 years ago

First paragraph is what not to do which I did, after that inquiring my interpretation of your first solution.

My response or the problem at first was to say that they must want us to use some trick to find out the reciprocated product of any distinct set of random prime numbers where the set contains an even number of elements. No way José. With the approach that you might be able to answer this question by counting up probablities quickly using combinatorics and such, the problem of finding the product of random prime numbers is inescapable in order to quantify the probability of each set of even numbers of primes. Then I read your solution and if im interpreting it correctly it’s super cool; are you saying either: 1) the closest I could come to interpreting your first solution is that with any set of random Hs and Ts, if one of the coins is fair, the cases of even and odd number of Hs are equally likely. If this is true though, I can’t help but think that it’s more complicated than that simply due to the fact that when finding the probability of some set of simultaneous outcomes 1/f(n1),1/f(n2)...1/f(nk) that if f(x) is an exploding or high derivative function like say f(x)=10^x, you can pretty much say that overcoming unlikelyhood with raw numbers certain to fail, and be near zero in likelyhood, at least for values as x approaches infinity. Pretty much, I was thinking that the chances of any Hs past a certain number p(k) would be zero. The closer you are to p(1)=2, the more heads there are but you can’t really determine the probability of each pair of random freakin prime numbers... I wouldn’t have considered your solution even if it was given as a hint or if i thought of it, so there must be something I’m missing in my thought process.

2) without a single fair coin, the probability of there being an even or odd number of heads (when all but the first coin, the fair one is flipped) is equal to one half (I say so because if the probability of the first fair coin is one half to be heads, and the answer to the Q is one half, then it must be that there is a 1/2 chance that the #Heads in the whole coin set will become either even or odd with the flipping of the first coin, meaning that the chances of #Heads to begin with without the first fair coin was also 1/2 anyway?

3) just based off of the fact that as you go down the line of coins, as H’s get more unlikely, the H’s get more spread out between more and more T’s, but the chance of the total number of Hs being a product of 2 is simply a matter of how many times did an increasingly unlikely outcome of Hs get produced with a sheer raw number of trials? Meaning that somehow(I can’t see how) the chances of this number being even is one half?”

Tristan Johnson - 3 years ago

Does that 2 bar sign stand for summation???

Mr. India - 3 years ago

Log in to reply

No it’s a product

Ankit Agarwal - 3 years ago

Log in to reply

Means,the product of all terms of this series?

Mr. India - 3 years ago

Log in to reply

@Mr. India Generally, both "term" and "series" are restricted to sums, so I would be careful about using those words; however, yes, we use the capital Pi for the product of factors enumerated by some value.

For an example that you probably will never see in practice, we can define the factorial as n ! = k = 1 n k n! = \prod_{k=1}^n k

Brian Moehring - 3 years ago

Log in to reply

@Brian Moehring Oh,thnx for telling

Mr. India - 3 years ago

Although, i think the so called "Amazing Fact 2" is a true statement, its explanation is not very solid. Because, if this explanation provides a valid logic, the Feller-Tornier constant should also be 1/2, and it's not.

Jack V. - 3 years ago

Log in to reply

Yeah, you need some assumption on the asymptotics of the sequence of probabilities for it to be true. "Bounded away from both 0 and 1" would work as a fairly strong condition, but there are surely more interesting (ie weaker) restrictions on the sequence.

Brian Moehring - 3 years ago
Hdjdms Shsnd
May 27, 2018

Ram can flip the coins in whatever order he wants without changing the answer to the problem. Let's say that that he's flipped all of the coins except for the single fair coin that he has. Whether he has an even or odd number of heads so far, the fair coin will make it a 50/50 whether there is an even or odd number after the last flip.

Brillient answer

Kapil Lodhi - 3 years ago

Log in to reply

estonishing

Anthony Pratt - 3 years ago

what if he flips all the coins and leave the 1/3 coin to be the last coin? wouldn't the answer change then?

Jackie Chen - 3 years ago

Log in to reply

In that case, we can be sure that the other coins have the same probability of having heads or tails (using the same reasoning with the 1/2 coin) so that the 1/3 probability that the even-ness will change does not affect the probability itself.

Wieter Jacobs - 3 years ago
Xu Liangjun
May 28, 2018

Let's assume Ram has N coins.

Let him flip the 2th-Nth coins first and throw the first coin at last, this won't change the probability.

Assume the probability of Ram flips 2th-Nth coins an odd number P o P_o , an even number P e P_e .

Assume the total probability of Ram flips 1th-Nth coins an odd number P o {P_o}^{'} , an even number P e {P_e}^{'} .

P o = 1 2 P o + 1 2 P e {P_o}^{'}=\frac{1}{2}P_o+\frac{1}{2}P_e

P e = 1 2 P o + 1 2 P e {P_e}^{'}=\frac{1}{2}P_o+\frac{1}{2}P_e

P e + P o = 1 {P_e}^{'}+{P_o}^{'}=1

Now you can see P o = 1 2 {P_o}^{'}=\frac{1}{2} .

is there any chance that he never flip a coin which is flipping head since we dont know whether 1/2+1/3+1/5+1/7+1/11+...is converge or not.

Tsz Chun Lam - 3 years ago

Log in to reply

Let's assume he has N coins.The possibility of him never flip a coin should be n = 1 n = N 1 p ( n ) \prod_{n=1}^{n=N}\frac{1}{p(n)}

Xu Liangjun - 3 years ago

We also know that the series 1/2+1/3+1/5+1/7... diverges.

https://en.m.wikipedia.org/wiki/Divergence of the sum of the reciprocals of the_primes

Darko Simonovic - 3 years ago

If the probability of getting head from 1st coin is not 1/2 then what will be the answer?

Siddhartha Roy - 3 years ago
Wenting Qiu
Jun 2, 2018

If we think in reverse order of the sequence of coins, the solution is very simple.

Let P1 denote the probability in question.

Let P2 denote the probability of flipping an even number of heads among the last 2017 coins after the first one in the sequence; thus 1-P2 denotes the probability of flipping an odd number of heads among the last 2017 coins.

Thus P1 = (1-P2) * probability of flipping the first coin head + P2 * probability of flipping the first coin tail

= (1-P2) (1/2) + P2 (1/2) = 1/2.

Kanad Pardeshi
May 30, 2018

Here's a slightly different solution: Let us say that the i t h i^th coin has a probability of 1 i \frac{1}{i} of landing heads. Obviously, the probability of it landing tails would be 1 1 i 1-\frac{1}{i} . Let us consider the sum ( 2017 1 ) ( 2016 1 ) ( 2015 1 ) . . . ( 3 1 ) ( 2 1 ) ( 1 1 ) 2018 ! \frac{(2017-1)(2016-1)(2015-1)...(3-1)(2-1)(1-1)}{2018!} .

This would be equal to P(even heads)-P(odd heads), as every term which turns out to be positive in the numerator contains f r a c 1 i frac{1}{i} an even number of times, and every negative term contains an odd number of heads. As is obvious, the above expression yields 0 0 . Hence, P(even heads)=P(odd heads).

Why do you say it is equal to P(even heads) - P(odd heads)? I don't see the logic. If I had a coin with P = 1/1 and one with P = 1/3, then your logic says P(even heads) - P(odd heads) = (1-1)(3-1)/3 = 0 but clearly the odds are not the same here.

Alex Li - 3 years ago

Log in to reply

The above expression can be said to be the continued product of

( ( 1 1 i ) ( 1 i ) ) ((1-\frac{1}{i})-(\frac{1}{i}))

from 1 through 2018. The first term is the probability of a tails showing up on that specific coin, and and the second term is the probability of a heads showing up on that coin. For a term in the continued product which has an odd number of heads, the term would be negative, and for an even number of heads, the term would be odd. This was the reason behind saying it to be P(even heads)-P(odd heads).

Also, in the above expression, you will have (0-1), and not (1-1), because of the explanation just above.

My apologies for not providing a detailed explanation. You see, I do not have a lot of experience in posting solutions here, and I'm still learning!!!

Kanad Pardeshi - 3 years ago

The chance is of adding +1 head is determined by p(k) on top of p(k+1) Since p(1) = 2 the chance of first coin is 50%. In this case it doesn't matter what chance p(2) .. p(n) yields for even, there is always a 50% to flip it from one way or the other.

let q(k)=1-p(k) here p(k)=k-th prime. then the answer is (P+Q)/2 where P=(p(1)+q(1)) (p(2)+q(2))..............................(p(2018)+q(2018)) Q=(q(1)-p(1)) (q(2)-p(2)) (q(3)-p(3)) .......................(q(2018-p(2018)) here we should not be in a hurry. people after reaching this stage may end up with a wrong answer. here we have to be very careful. here q(1)=p(1) as p(1)=1/2. if we ignore this fact we will end up with a wrong answer inspite of all the hardwork. from this we get Q=0 hence the answer is 0.5

Srikanth Tupurani - 3 years ago
Al Al
May 30, 2018

Assume we throw the coins in order, so that the nth coin has a heads-probability of 1 / π [ n ] 1/\pi[n] where π [ n ] \pi[n] is the nth prime.

Let P [ n ] P[n] be the probability of having an even number of heads after throwing the nth coin. Then, we can establish the following recurrence relation:

P [ n ] = 1 π [ n ] ( 1 P [ n 1 ] ) + ( 1 1 π [ n ] ) P [ n 1 ] P[n]=\frac{1}{\pi[n]}(1-P[n-1])+(1-\frac{1}{\pi[n]})P[n-1] .

The equation can be explained as follows:

Left side: probability of having an even number of heads at step n. Right side, first term: multiply the probability of having an odd number of heads at step n-1 by the probability of getting heads at step n. Right side, second term: multiply the probability of having an even number of heads at step n-1 by the probability of getting tails at step n.

We can rearrange the expression as:

P [ n ] = P [ n 1 ] + ( 1 2 P [ n 1 ] ) π [ n ] P[n]=P[n-1]+\frac{(1-2P[n-1])}{\pi[n]}

Now, we know that P [ 1 ] P[1] is the probability of obtaining an even number of heads after just one throw. This means the probability of getting tails. We simply get P [ 1 ] = 1 / 2 P[1]=1/2 . Now let's try P[2], and focus on the term ( 1 2 P [ n 1 ] ) (1-2P[n-1]) which is clearly 0. Then, P [ 2 ] = P [ 1 ] P[2]=P[1] . You can iterate as many times as you want and get P [ n ] = P [ n 1 ] P[n]=P[n-1] , so for any value of n you get a 1/2 probability of an even number of heads.

Hamana Hamana
May 29, 2018

Not a solution, but curious nonetheless...

By writing a program in java to test the probability, I got (approximately) the correct answer of 1/2.

Doing the same thing with random probabilities instead of probability 1/p(k) gave the same answer of 1/2.

Doing it again, guaranteeing there was no coin probability of 1/2, gave me the same answer of 1/2.

This tells me that the coin bias doesn’t matter; the probability of an even number of heads, with 2018 coins, will always be 1/2.

You are on the right track! As the number of coins tends towards infinity, the probability tends towards 1/2. I added an extra solution that explains why this happens.

Ankit Agarwal - 3 years ago

Log in to reply

Thank you! Makes more sense to me now.

Hamana Hamana - 3 years ago

If there is a fair coin in the mix (probability of 1/2 for heads) an even number of heads will have probability 1/2. Otherwise, the probability of even heads might be close to 1/2, but will not be equal to 1/2. (Consider a case of 3 coins, heads probabilities of 1/3, 1/5, and 1/7. The probability of an even number of heads is not 1/2.)

Brian Galebach - 3 years ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...