View Single Post
  #5   Report Post  
Steved
 
Posts: n/a
Default

Hello Andrea from Steved

I ran your Lottery function to get
8.736513138
32.51254272
47.04566193
17.73767471
47.16249466

As you can see I've got 47 twice

Question what am I doing wrong please and what is require please to generate
6 numbers.

Thankyou.


"Andrea Jones" wrote:

I've run 122757 iterations using this macro and there is no bias towards high
or low values. I should have mentioned that all the variables are declared
as integers, I just wanted to give the gist of the code rather than the whole
thing. When I ran this so that the average number of occurrences for each
number was 2455 (122757 iterations) the number 50 occurred 2369 times.

Andrea Jones
http://www.allaboutoffice.co.uk
http://www.stratatraining.co.uk
http://www.allaboutclait.com

"JE McGimpsey" wrote:

Couple of caveats, he

0) Everything that follows is useless for choosing or predicting numbers
in an external lottery. Playing 1-2-3-4-5 is just as sound a strategy as
playing a randomly generated number, assuming a fair game. If you're
generating your own lottery's random numbers, read on.

1) Unless a,b,c,d and e are declared as Integers or Longs (which may not
be "obvious" at first, this routine generates non-integers, which aren't
very useful for lottery numbers.

2) The claimed range is [1-50], the actual range is [0-50].

3) Using Timer to bias each number doesn't seem to me to "make better
random numbers" than using Randomize once. Since Seed2-Int(Seed2) = 0,
it will tend to bias the results away from 0.

4) In MacXL, using Seed2-Int(Seed2) doesn't do anything since Timer
returns an integer.

5) In the case where Seed2-Int(Seed2) produces a value 0, using a cap
of 50 will tend to bias upward the number of times 50 is produced.

One way to get N random integers from a universe of M integers can be
found at

http://www.mcgimpsey.com/excel/randint.html



In article ,
Andrea Jones wrote:

Here's some code that will make better random numbers for you so you don't
keep getting the same answers (you'll obviously have to declare the variables
a, b, c, etc first), it generates 5 random numbers in the range 1-50: