|
|
|
|
|
by gus_massa
2953 days ago
|
|
> 2) I told each of the developers should run "echo $RANDOM" and then multiply them all. This doesn't work very well, because the distribution would be very uneven. There is a high chance (93.75%) that at least one of the developers get an even number, so if you multiply them you will get an even result. Moreover, if some of the developer get a multiple of 4 or two of them get a multiple of 2, then the result is a multiple of 4, so the restaurants with a number that is a multiple of 4 have a much higher probability (but I'm too lazy to do the calculation now). There is something similar with the restaurant that have an index that is a multiple of 5 (and I'm still lazy). So the restaurant with the number 20 (or 0) has the highest probability of been selected. As a though experiment, just imagine that you have 20 restaurants and 100 developers. It' almost sure that one of them will get a multiple of 4 and another a multiple of 5, and the multiplication will be a multiple of 20. The problem is that in the multiplication modulo 20, the numbers 2 (and 4) and 5 are special. If you add the four random numbers instead of multiplying them, the problem is automatically solved. |
|