Загрузка страницы

Implement a fair coin given an unfair coin

Given an unfair coin, where probability of heads coming up is P and tails is (1-P). Implement a fair coin from the given unfair coin.

Algorithm:
Let us define an event.
An event is defined as flipping the unfair coin twice.
Let us observe probability of all possible events.
Event 1: Probability of heads coming up in both is P*P
Event 2: Probability of tails coming up in both is (1-P)* (1-P)
Event 3: Probability of heads coming up in first and tails in second is P*(1-P)
Event 4: Probability of tails coming up in first and heads in second is (1-P)*P
If you observe carefully, you would notice that events 3rd and 4th occur with equal probability of P*(1-P).
So, if we ignore events 1st and 2nd of getting both heads or tails, since they have different probabilities, we are left with events 3rd and 4th which occur with equal probability.
So, Keep flipping the unfair coin two at a time, until they come up with different values, then return value of first flip of the coin (out of the two flips).

We have used probability theory formulas here without going into the details of proofs and theory. Curious readers can check out wiki links on these topics.

Sometimes this problem is also asked as:
Make a fair coin from a biased coin
Simulate a fair coin toss with a biased coin
How to make a biased coin unbiased
Biased coin to fair coin
Getting a Fair Toss From a Biased Coin
Write a function which returns true and false with equal probability

Code and Algorithm Visualization:
Coming soon on http://www.ideserve.co.in. Stay Tuned!

Website: http://www.ideserve.co.in

Facebook: https://www.facebook.com/IDeserve.co.in

Видео Implement a fair coin given an unfair coin канала IDeserve
Показать
Комментарии отсутствуют
Введите заголовок:

Введите адрес ссылки:

Введите адрес видео с YouTube:

Зарегистрируйтесь или войдите с
Информация о видео
20 апреля 2016 г. 16:25:40
00:06:52
Яндекс.Метрика