darts dice and coins
play

Darts, Dice, and Coins Sampling from a Discrete Distribution The - PowerPoint PPT Presentation

Darts, Dice, and Coins Sampling from a Discrete Distribution The Problem Statement You are given an n-sided loaded die with probabilities p 1 , p 2 , , p n of sides 1, 2, , n coming up. What is the most efficient algorithm for


  1. A Sample Loaded Die How do we know what we ● A four-sided die: hit? ● p 1 = 1/2 ● p 2 = 1/3 Throw Again! ● p 3 = 1/12 1 ● p 4 = 1/12 2 3 4

  2. A Sample Loaded Die How do we know what we ● A four-sided die: hit? ● p 1 = 1/2 ● p 2 = 1/3 ● p 3 = 1/12 1 ● p 4 = 1/12 2 3 4

  3. A Sample Loaded Die How do we know what we ● A four-sided die: hit? ● p 1 = 1/2 ● p 2 = 1/3 ● p 3 = 1/12 1 ● p 4 = 1/12 2 Each column has the same width. 3 4 Each column has only two options.

  4. A Sample Loaded Die How do we know what we ● A four-sided die: hit? ● p 1 = 1/2 ● p 2 = 1/3 ● p 3 = 1/12 1 ● p 4 = 1/12 2 Choose the column by rolling a fair die. 3 4 Each column has only two options.

  5. A Sample Loaded Die How do we know what we ● A four-sided die: hit? ● p 1 = 1/2 ● p 2 = 1/3 ● p 3 = 1/12 1 ● p 4 = 1/12 2 Choose the column by rolling a fair die. 3 4 Each column has only two options.

  6. A Sample Loaded Die How do we know what we ● A four-sided die: hit? ● p 1 = 1/2 ● p 2 = 1/3 ● p 3 = 1/12 1 ● p 4 = 1/12 2 Choose the column by rolling a fair die. 3 4 Choose which part of the column by flipping a biased coin.

  7. Throwing a dart at this board is equivalent to rolling 1 a fair die, then 2 flipping one of many biased coins. 3 4

  8. Throwing a dart at this board is equivalent to rolling 1 a fair die, then 2/3 flipping one of many biased coins. 1/6 1/6

  9. The Dartboard Algorithm ● Build the target by dividing all probabilities by the largest probability. ● Until you choose a side: 1 ● Roll a fair die to choose a column. 2/3 ● Flip the coin in that column. ● If it's heads, output the 1/6 1/6 column.

  10. Not All Dartboards are Equal

  11. Not All Dartboards are Equal

  12. Not All Dartboards are Equal ● If the die is close to being fair, the probability of missing is very low. ● As the die becomes more unfair, the probability of missing keeps increasing. ● In the limit, the dartboard might have n – 1 out of n columns always fail.

  13. Not All Dartboards are Equal ● If the die is close to being fair, the probability of missing is very low. ● As the die becomes more unfair, the probability of missing keeps increasing. ● In the limit, the dartboard might have n – 1 out of n columns always fail.

  14. Not All Dartboards are Equal ● If the die is close to being fair, the probability of missing is very low. ● As the die becomes more unfair, the probability of missing keeps increasing. ● In the limit, the dartboard might have n – 1 out of n columns always fail.

  15. Not All Dartboards are Equal ● If the die is close to being fair, the probability of missing is very low. ● As the die becomes more unfair, the probability of missing keeps increasing. ● In the limit, the dartboard might have n – 1 out of n columns always fail.

  16. Not All Dartboards are Equal ● If the die is close to being fair, the probability of missing is very low. ● As the die becomes more unfair, the probability of missing keeps increasing. ● In the limit, the dartboard might have n – 1 out of n columns always fail.

  17. Not All Dartboards are Equal ● If the die is close to being fair, the probability of missing is very low. ● As the die becomes more unfair, the probability of missing keeps increasing. ● In the limit, the dartboard might have n – 1 out of n columns always fail.

  18. Not All Dartboards are Equal ● If the die is close to being fair, the probability of missing is very low. ● As the die becomes more unfair, the probability of missing keeps increasing. ● In the limit, the dartboard might have n – 1 out of n columns always fail.

  19. Not All Dartboards are Equal ● Perfectly fair die: O(1) dart tosses required. ● Perfectly biased die: O(n) dart tosses required on expectation. ● General expected number of dart tosses: O(n p max )

  20. Can we get rid of the empty space?

  21. Getting Rid of Spaces ● A four-sided die: ● p 1 = 1/2 ● p 2 = 1/3 ● p 3 = 1/12 1/2 ● p 4 = 1/12 1/3 1/12 1/12

  22. Getting Rid of Spaces ● A four-sided die: ● p 1 = 1/2 ● p 2 = 1/3 ● p 3 = 1/12 1/2 ● p 4 = 1/12 1/3 1/12 1/12

  23. Getting Rid of Spaces ● A four-sided die: ● p 1 = 1/2 ● p 2 = 1/3 Height is ● p 3 = 1/12 ½, the 1/2 ● p 4 = 1/12 maximum of these 1/3 values. 1/12 1/12

  24. Getting Rid of Spaces ● A four-sided die: ● p 1 = 1/2 ● p 2 = 1/3 ● p 3 = 1/12 1/2 ● p 4 = 1/12 1/3 1/12 1/12

  25. Getting Rid of Spaces ● A four-sided die: ● p 1 = 1/2 ● p 2 = 1/3 ● p 3 = 1/12 1/2 ● p 4 = 1/12 Height is 1/3 ¼, the average of these 1/12 1/12 values.

  26. Getting Rid of Spaces ● A four-sided die: ● p 1 = 1/2 ● p 2 = 1/3 ● p 3 = 1/12 1/2 ● p 4 = 1/12 1/3 1/3 1/12 1/12

  27. Getting Rid of Spaces ● A four-sided die: ● p 1 = 1/2 ● p 2 = 1/3 ● p 3 = 1/12 1/2 ● p 4 = 1/12 1/12 1/4 1/12 1/12

  28. Getting Rid of Spaces ● A four-sided die: ● p 1 = 1/2 ● p 2 = 1/3 ● p 3 = 1/12 ● p 4 = 1/12 1/12 1/4 1/4 1/4 1/12 1/12

  29. Getting Rid of Spaces ● A four-sided die: We have gotten rid of the blank spaces. Every dart ● p 1 = 1/2 tossed will hit something! ● p 2 = 1/3 ● p 3 = 1/12 ● p 4 = 1/12 1/12 1/4 1/4 1/4 1/12 1/12

  30. Getting Rid of Spaces ● A four-sided die: We have gotten rid of the blank spaces. Every dart ● p 1 = 1/2 tossed will hit something! ● p 2 = 1/3 But now, each column isn't a ● p 3 = 1/12 biased coin. ● p 4 = 1/12 1/12 1/4 1/4 1/4 1/12 1/12

  31. Getting Rid of Spaces ● A four-sided die: We have gotten rid of the blank spaces. Every dart ● p 1 = 1/2 tossed will hit something! ● p 2 = 1/3 But now, each column isn't a ● p 3 = 1/12 biased coin. ● p 4 = 1/12 1/12 1/4 1/4 1/4 1/12 1/12

  32. Getting Rid of Spaces ● A four-sided die: ● p 1 = 1/2 ● p 2 = 1/3 ● p 3 = 1/12 1/2 ● p 4 = 1/12 1/3 1/12 1/12

  33. Getting Rid of Spaces Goal: Reshape this ● A four-sided die: setup so that each column has at most ● p 1 = 1/2 two different ● p 2 = 1/3 blocks. ● p 3 = 1/12 1/2 ● p 4 = 1/12 1/3 1/12 1/12

  34. Getting Rid of Spaces Goal: Reshape this ● A four-sided die: setup so that each column has at most ● p 1 = 1/2 two different ● p 2 = 1/3 blocks. ● p 3 = 1/12 1/2 ● p 4 = 1/12 1/6 1/6 1/12 1/12

  35. Getting Rid of Spaces Goal: Reshape this ● A four-sided die: setup so that each column has at most ● p 1 = 1/2 two different ● p 2 = 1/3 blocks. ● p 3 = 1/12 ● p 4 = 1/12 1/6 1/6 5/12 1/6 1/12 1/12

  36. Getting Rid of Spaces Goal: Reshape this ● A four-sided die: setup so that each column has at most ● p 1 = 1/2 two different ● p 2 = 1/3 blocks. ● p 3 = 1/12 ● p 4 = 1/12 1/12 1/6 1/6 1/4 1/6 1/12 1/12

  37. We can choose the dart's x coordinate by rolling a fair die. We can choose the dart's y coordinate by flipping a 1/12 biased coin. 1/6 1/6 1/4 If the coin yields heads, 1/6 output the lower half as the 1/12 1/12 answer. If the coin yields tails, output the upper half as the answer.

  38. We can choose the dart's x coordinate by rolling a fair die. We can choose the dart's y coordinate by flipping a 1/3 biased coin. 2/3 2/3 1 If the coin yields heads, 2/3 output the lower half as the 1/3 1/3 answer. If the coin yields tails, output the upper half as the answer.

  39. We can choose the dart's x coordinate by rolling a fair die. We can choose the dart's y coordinate by flipping a 1/12 1/3 biased coin. 1/6 2/3 1/6 2/3 1/4 1 If the coin yields heads, 1/6 2/3 output the lower half as the 1/12 1/12 1/3 1/3 answer. If the coin yields tails, output the upper half as the answer.

  40. We can choose the dart's x coordinate by rolling a fair die. We can choose the dart's y coordinate by flipping a 1/12 1/3 biased coin. 1/6 2/3 1/6 2/3 1/4 1 If the coin yields heads, 1/6 2/3 output the lower half as the 1/12 1/12 1/3 1/3 answer. If the coin yields tails, output the upper half as the answer.

  41. We can choose the dart's x coordinate by rolling a fair die. We can choose the dart's y coordinate by flipping a 1/12 1/3 biased coin. 1/6 2/3 1/6 2/3 1/4 1 If the coin yields heads, 1/6 2/3 output the lower half as the 1/12 1/12 1/3 1/3 answer. If the coin yields tails, output the upper half as the answer.

  42. We can choose the dart's x coordinate by rolling a fair die. We can choose the dart's y coordinate by flipping a 1/12 1/3 biased coin. 1/6 2/3 1/6 2/3 1/4 1 If the coin yields heads, 1/6 2/3 output the lower half as the 1/12 1/12 1/3 1/3 answer. If the coin yields tails, output the upper half as the answer.

  43. The Alias Method ● Distribute probabilities such that ● Each column has height 1 / n ● Each column has at most two blocks in 1/12 1/3 it. 2/3 1/6 1/6 2/3 ● To generate a roll of the die: 1/4 1 ● Roll a fair die to choose the column. 1/6 2/3 ● Flip a biased coin to choose the upper 1/12 1/12 1/3 1/3 or lower block. ● Generation time is now O(1) .

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend