00:00 - 00:03 | We have a new task. |
00:04 - 00:05 | Given a method rand5() that generates random numbers [1, 2, 3, 4, 5] uniformly distributed |
00:05 - 00:07 | write a method rand7() that generates random numbers [1, 2, 3, 4, 5, 6, 7] uniformly distributed in that range |
00:08 - 00:12 | The solution should not use any other method call other than rand5(). |
00:12 - 00:15 | We can try sum them and just mod the result |
00:17 - 00:19 | Sums of a uniformly random numbers are not uniformly random |
00:19 - 00:21 | the numbers in the middle have more probability than the numbers near edges |
00:24 - 00:26 | Use Sum to select a Sum-th number from 12345671234567..... |
00:27 - 00:28 | Sumthe berni!!!! |
00:31 - 00:33 | Again, sums of a uniformly random numbers are not uniformly random. Can't use a sum. |
00:34 - 00:36 | I think brother Nick is right here is a simulation using what he suggested and its uniform |
00:53 - 00:58 | Numbers 1, 6, and 7 are being consistently generated with higher frequently than 2, 3, 4, and 5. Can you explain? |
01:13 - 01:15 | No Summing of Random numbers! |
01:15 - 01:17 | No SUM!!! NO SUM!!! |
01:18 - 01:23 | By the way you If you are running on windows, restart the system. |
01:25 - 01:28 | Reboot did not help?? Must be Linux. |
01:29 - 01:31 | So, as I explained, once you start summing two uniformly random numbers |
01:31 - 01:34 | the distribution function is no longer uniform (it has a bell shape) and there is no way |
01:34 - 01:37 | A viable strategy that can be adopted to solve this problem is based on "rejection". Here are two basic ideas: |
01:37 - 01:40 | Method 1/ Method2 |
01:40 - 01:42 | Raw and column selection is a summing function. The principle is the same. |
01:42 - 01:46 | Its not the same, one is using 1 dimensional while the other is 2D!! |
01:46 - 01:48 | Its the same, Select [ 5*rand5() + rand5() ]-th number Try again if you run out of numbers |
01:48 - 01:52 | NO NO NO its not come on its 1D vs 2D |
01:53 - 01:57 | Dont you Get it! Its like 100% more dimensions. |