Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: Lottery Script
03-28-2009, 04:36 PM #1
- Join Date
- Feb 2005
- Bradford, UK
- Thanked 66 Times in 65 Posts
I'm writing a script to help me pick lottery numbers. Its supposed to come up with the most common individual numbers and most common combinations but its coming up with a strange result.
There are approx 14 million possible combinations, out of 100,000 loops I would expect most of those 100,000 to be unique combinations but what I'm actually getting (and its the same every time I run it) is that it only comes out with 5174 unique combinations (and its that exact same number every time). Roughly half the combinations come out 20 times and the other half come out 19 times. So either this is just a quirk of the random number generator or theres something wrong with my code.
$n = rand(1,49);
Last edited by NancyJ; 03-28-2009 at 04:45 PM.
03-28-2009, 05:05 PM #2
- Join Date
- Dec 2007
- Thanked 890 Times in 879 Posts
- array(0) will insert a 0 at first position of $comb.
- in while you test $n if is in $comb before you use rand to set a value, use a do-while instead
if you look to the $numbers you will see that is not a gaussian distribution but this is because of function rand.
probably you already know that you will never get 100000 combination as far as you don't force that in the same way you do in the inner loop.