# Random number challenge

Corey Edwards tensai at zmonkey.org
Fri Jun 27 02:03:28 MDT 2008

```On Thu, 2008-06-12 at 09:28 -0600, Jason Hall wrote:
> On Thu, Jun 12, 2008 at 9:24 AM, Andrew Jorgensen
> <andrew at jorgensenfamily.us> wrote:
> > What's the process on the binary grab bag?  It's been a while.
>
> Everybody counts off 1-\$MAX
> Flip a coin, Heads sets the bit, tails is a blank bit.
> Flip until you have the bits necessary to represent \$MAX
> Congrats, you have a number for the winner of the first item.

Something about that method just didn't sit right with me. Seemed like
some numbers would come out more often than others. So I sat down and
coded up a simulator to see if I was right. According to my results,
this particular distribution method unfairly favors some numbers
whenever the sample size (\$MAX) is not an even multiple of 2 (2, 4, 8,
etc.).

I've attached my simulator. Here are a couple of simple examples which I
think will illustrate the point:

[cedwards at pheasant binary-grab-bag]\$ ./simulate.pl 7 1000 |sort
-n
0 = 115
1 = 122
2 = 135
3 = 244
4 = 123
5 = 114
6 = 147
[cedwards at pheasant binary-grab-bag]\$ ./simulate.pl 8 1000 |sort
-n
0 = 132
1 = 152
2 = 131
3 = 138
4 = 114
5 = 114
6 = 115
7 = 104

When there are only 7 people, being person #3 seems to pay off. But when
there are 8, the prize is pretty evenly distributed, give or take a few.
Different numbers of contestants have their own consistent patterns
which could, with a little pre-calculation and some head counting, be
used by a Fugal to cheat the system. The simplest method would be to
stay close to the center.

So, while the binary grab bag system is high on geek points, I recommend
we find a new strategy.

Corey

-------------- next part --------------
A non-text attachment was scrubbed...
Name: simulate.pl
Type: application/x-perl
Size: 1780 bytes
Desc: not available
Url : http://plug.org/pipermail/plug/attachments/20080627/d12330da/attachment.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://plug.org/pipermail/plug/attachments/20080627/d12330da/attachment-0001.bin
```