random number generator

J

jvoortman

is it possible to make a random number generator in excel.
I am part of a dart elague which has a number drawn out of
a bucket each week towin a prize. There are 420 players in
the league and what they have been doing up til now is
pulling number out of a hat and then matching them up with
a master list with players name corresponding to a number
i.e. John # 1, Bill #2 .....Fred #413 etc
 
B

Bill Kuunders

one way

=ROUND(RAND()*420,0)
and use the result as a basis for a vlookup to find the name in your list

Bill K
 
J

james

hi just curious,
why do you multiply by 420?


-----Original Message-----
one way

=ROUND(RAND()*420,0)
and use the result as a basis for a vlookup to find the name in your list

Bill K



.
 
B

BenjieLop

Assume that column A (from A2:A422) contains the name of the players
Enter this formula in Cell B2

=round(rand()*420,0)

and copy down until Cell B422.

And, if you want to change the numbers generated across the names o
the players, press F9 and the numbers will change.

I hope this works for you.
 
B

BenjieLop

You have 420 entries, that's why. If your league participants increas
to, say, 500,
change the 420 in your formula to 500.
 
B

Bill Kuunders

As I understand, the rand() function returns a number between 1 and 0 or in
other words a percentage.
Regards
Bill K
 
J

Jim May

BenjieLop:
Copying down as you suggest I get lots of Duplicates, and sometime
triplicates;
This would surely start a brawl over who won, right?
 
M

Myrna Larson

Put the numbers 1 to 420 in, say, A1:A420 (you can do that easily with
Edit/Fill/Series). In B1, put the formula =RAND() and copy down through B420.
Sort the data on column B. Designate the number now in A1 as the winner.

BenjieLop:
Copying down as you suggest I get lots of Duplicates, and sometime
triplicates;
This would surely start a brawl over who won, right?
 
B

BenjieLop

Yes, this issue skipped my mind. In fact, when I did this for 100 name
in one of my applications, I encountered duplicates and triplicates, a
well.

To "solve" this issue, I changed the number 100 (in the random formula
to 1000 and this took care of the duplicates and triplicates. Later on
I realized that I had another solution since all I wanted to do wa
rank the entries anyway.

Basically, you just want to "rank" the players from top to botto
(depending on the random number generated) and there are a lot of way
to accomplish this even with duplicates and triplicates and, mayb
even, quadruplicates.

Myrna Larson has also given you a suggestion on how to take care o
ranking your players.

You can also read Charles Pearson's "Data Sort By Ranking." Hi
example is an excellent model for your application.

Regards.
 
B

BenjieLop

I APOLOGIZE because I misunderstood your post. I reread it and I realiz
that all you wanted to determine was ONE WINNER from a total of 42
entries. My "ranking" suggestion is not applicable then.

The suggestions from Myrna Larson and Alex Delamain are what will wor
for you. Again, I apologize for suggesting a solution that is no
applicable in your situation.
 
B

Bill Kuunders

And my solution of a vlookup function doesn't???
=VLOOKUP(C1,A1:B240,2)
where C1 = ROUND(RAND()*240
and A1:B240 is the player list

or you simply combine the two into one
=VLOOKUP(ROUND(RAND()*240,0),A1:B240,2)
I tried it .
It works
And you do not need to sort anything.

Kind Regards :)
Bill K
 
M

Myrna Larson

I have to take issue with your formula to get from RAND() to a number between
1 and 240. It doesn't give every person an equal chance of being selected.

The "standard" formula for getting a random integer between 1 and N is

=INT(RAND()*N)+1

You want to generate a random number, which starts out in the range >=0, < 1,
and categorize it into one of 240 bins of *equal* size, so you multiply by
240. Assuming no problems with the RNG, RAND()*240 will give you a uniform
distribution between 0 and 239.99999999. No problem so far.

But you can't ROUND those numbers to get values between 1 and 240.

First, 0.5 will always round up. That's biased. It should round up half of the
time and down half of the time. (I expect that's more of a theoretical problem
than a real issue here.)

Second issue is the width of the bins: numbers >= 0.50 and < 1.5 will round to
1, >= 1.5 and < 2.5 will round to 2, etc. That's fine: for each of those bins
the width is 1.

But there are problems at the ends of the range:

Values >= 0 and < 0.5 will round to 0. The width of that bin is only half of
what it should be.

And at the other end, numbers between 239.5 and 240 will round to 240. Again,
this bin is only half-size.

So you have 239 bins of the correct size and 2 that are only half-size. IOW,
the distribution is not uniform.

This causes 2 problems:

(a) there's probably no "Person 0", so you'll get an error if RAND()*240 <
0.5; the chances of that are ~ 1/480, but they are not 0;

(b) the person at the end of the list, #240, has only half the chance of being
selected as the other persons; this is, IMO, significant.

I did the following to illustrate. I generated 65000 random integers between 1
and 10, so each number would occur with a frequency of about 6500.

In A1:A65000 I put the formula =RAND()*10
In B1, =ROUND(A1,0) and copy down
In C1, =INT(A1)+1 and copy down

I did histograms on columns B and C, with bins numbered 0 to 11. That's 12
bins, and the first and last *should* be empty.

Here's the histogram data:

Column B numbers Column C numbers
Bin Freq Bin Freq
0 3266 <<< 0 0 <<<
1 6597 1 6502
2 6632 2 6412
3 6338 3 6433
4 6518 4 6667
5 6375 5 6654
6 6495 6 6530
7 6414 7 6403
8 6621 8 6359
9 6573 9 6553
10 3171 <<< 10 6487
11 0 11 0 <<<

Note the column B formula distributes the numbers into 11 bins instead of 10:
the 9 middle bins have values between 6338 and 6632, the two at the ends are
roughly "half-size", with only 3266 and 3171 values, respectively.

OTOH, with the correct formula, in column C, there are only 10 bins containing
data, all of about the same size (range 6359-6667).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top