Hi,
I've written a lottery programme in PHP that selects 10 winners a week
from approximately 18,000 shares.
The problem I have is that of the ten winners one week the same share
number was drawn the next week and an adjacent share number the
following week (that just happened to be owned by the same member)
The program is now being looked at suspisciously.
The main core of the random draw simply puts all the current share
numbers into an array ($currWinner), draws a random number using the
rand function between 1 and the number of shares ($lottshares) and
returns the share id number.
for the random element ofthe program I use:
$currWinner = rand(1,$lottShares);
is this random enough? or is it possible that it needs seeding (although
I don't totally understand seeding?
Any help will be appreciated.
thanks
Kevin 11 3514
Kevin Williamson wrote:
Hi,
I've written a lottery programme in PHP that selects 10 winners a week
from approximately 18,000 shares.
The problem I have is that of the ten winners one week the same share
number was drawn the next week and an adjacent share number the
following week (that just happened to be owned by the same member)
The program is now being looked at suspisciously.
The main core of the random draw simply puts all the current share
numbers into an array ($currWinner), draws a random number using the
rand function between 1 and the number of shares ($lottshares) and
returns the share id number.
for the random element ofthe program I use:
$currWinner = rand(1,$lottShares);
is this random enough? or is it possible that it needs seeding (although
I don't totally understand seeding?
Any help will be appreciated.
thanks
Kevin
Kevin,
Yes, I admit that does look suspicious! Of course, it's always possible
for it to happen, but the when you're drawing 10 out of 18K are much
against it :-)
Which version of PHP are you running? The reason I asked, versions
before 4.2 did not automatically seed the random number generator - you
need to do it. See srand().
Version 4.2 and later do this automatically if the generator hasn't been
seeded.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attglobal.net
==================
Kevin Williamson wrote:
Hi,
I've written a lottery programme in PHP that selects 10 winners a week
from approximately 18,000 shares.
The problem I have is that of the ten winners one week the same share
number was drawn the next week and an adjacent share number the
following week (that just happened to be owned by the same member)
The program is now being looked at suspisciously.
The main core of the random draw simply puts all the current share
numbers into an array ($currWinner), draws a random number using the
rand function between 1 and the number of shares ($lottshares) and
returns the share id number.
for the random element ofthe program I use:
$currWinner = rand(1,$lottShares);
is this random enough? or is it possible that it needs seeding (although
I don't totally understand seeding?
Any help will be appreciated.
thanks
Kevin
While (all things being random) it isn't technically impossible, it is
suspicious. Aside from the PHP version seeding issue Jerry mentioned,
you may want to just run a big simulation, running a few thousand
"drawings", then get the number of occurances of each share.
If it looks like a few numbers start jumping out more often than
others, you may have a problem. Ideally, in a truely random system,
when run for a sufficiently large set, all shares should have
relatively the same number of occurances.
On Fri, 10 Nov 2006 21:15:01 GMT, Kevin Williamson
<ke***************@ntlworld.comwrote:
>I've written a lottery programme in PHP that selects 10 winners a week from approximately 18,000 shares.
The problem I have is that of the ten winners one week the same share number was drawn the next week and an adjacent share number the following week (that just happened to be owned by the same member) The program is now being looked at suspisciously.
How many times has the draw been done? Based on the information given there's
no firm evidence that anything's wrong - the people looking at it may be
falling for the Gambler's Fallacy.
>The main core of the random draw simply puts all the current share numbers into an array ($currWinner), draws a random number using the rand function between 1 and the number of shares ($lottshares) and returns the share id number.
for the random element ofthe program I use:
$currWinner = rand(1,$lottShares);
is this random enough?
I believe rand() uses your operating system's default rand() system call, so
the quality of the pseudo-random numbers depends on your system. Generally this
is still "random enough", but that depends on your definition. If there's money
involved, then maybe not.
There's also mt_rand() which uses the Mersenne Twister algorithm, which has
some advantages over some other pseudo-random number generators. It's still
pseudo-random, but "real" randomness generally needs hardware based on some
random physical phenomenon (thermal noise, radioactive decay, etc.)
You should test your system by setting up a simple test harness that runs the
script some large number of times and saving the results. You can then analyse
the results to see if there are any obvious groupings, or whether the
distribution is roughly uniform.
>or is it possible that it needs seeding (although I don't totally understand seeding?
That depends on your PHP version - only older versions need to be explicitly
seeded.
--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Thanks Jerry,
I'm not sure what version of PHP because I installed it on an intranet
and unless I visit the company do not have access to check.
I have had the guy send me the relevant file that contains the draw
sequence to have a look at. I think I'll use srand as a matter of course
and return the updated version...but I agree ... look suspect
thanks again
Kevin
Jerry Stuckle wrote:
Kevin Williamson wrote:
>Hi,
I've written a lottery programme in PHP that selects 10 winners a week from approximately 18,000 shares.
The problem I have is that of the ten winners one week the same share number was drawn the next week and an adjacent share number the following week (that just happened to be owned by the same member) The program is now being looked at suspisciously.
The main core of the random draw simply puts all the current share numbers into an array ($currWinner), draws a random number using the rand function between 1 and the number of shares ($lottshares) and returns the share id number.
for the random element ofthe program I use:
$currWinner = rand(1,$lottShares);
is this random enough? or is it possible that it needs seeding (although I don't totally understand seeding?
Any help will be appreciated.
thanks Kevin
Kevin,
Yes, I admit that does look suspicious! Of course, it's always possible
for it to happen, but the when you're drawing 10 out of 18K are much
against it :-)
Which version of PHP are you running? The reason I asked, versions
before 4.2 did not automatically seed the random number generator - you
need to do it. See srand().
Version 4.2 and later do this automatically if the generator hasn't been
seeded.
Thanks Moot,
In view of the advice received I'll use a seed and run a test with
several thousand draws just to make sure.
I appreciate the help
Kevin
Moot wrote:
Kevin Williamson wrote:
>Hi,
I've written a lottery programme in PHP that selects 10 winners a week from approximately 18,000 shares.
The problem I have is that of the ten winners one week the same share number was drawn the next week and an adjacent share number the following week (that just happened to be owned by the same member) The program is now being looked at suspisciously.
The main core of the random draw simply puts all the current share numbers into an array ($currWinner), draws a random number using the rand function between 1 and the number of shares ($lottshares) and returns the share id number.
for the random element ofthe program I use:
$currWinner = rand(1,$lottShares);
is this random enough? or is it possible that it needs seeding (although I don't totally understand seeding?
Any help will be appreciated.
thanks Kevin
While (all things being random) it isn't technically impossible, it is
suspicious. Aside from the PHP version seeding issue Jerry mentioned,
you may want to just run a big simulation, running a few thousand
"drawings", then get the number of occurances of each share.
If it looks like a few numbers start jumping out more often than
others, you may have a problem. Ideally, in a truely random system,
when run for a sufficiently large set, all shares should have
relatively the same number of occurances.
Thanks Andy,
In view of the advice received I'll use a seed and run a test with
several thousand draws just to make sure.
I appreciate the help
Kevin
Andy Hassall wrote:
On Fri, 10 Nov 2006 21:15:01 GMT, Kevin Williamson
<ke***************@ntlworld.comwrote:
>I've written a lottery programme in PHP that selects 10 winners a week from approximately 18,000 shares. The problem I have is that of the ten winners one week the same share number was drawn the next week and an adjacent share number the following week (that just happened to be owned by the same member) The program is now being looked at suspisciously.
How many times has the draw been done? Based on the information given there's
no firm evidence that anything's wrong - the people looking at it may be
falling for the Gambler's Fallacy.
>The main core of the random draw simply puts all the current share numbers into an array ($currWinner), draws a random number using the rand function between 1 and the number of shares ($lottshares) and returns the share id number.
for the random element ofthe program I use:
$currWinner = rand(1,$lottShares);
is this random enough?
I believe rand() uses your operating system's default rand() system call, so
the quality of the pseudo-random numbers depends on your system. Generally this
is still "random enough", but that depends on your definition. If there's money
involved, then maybe not.
There's also mt_rand() which uses the Mersenne Twister algorithm, which has
some advantages over some other pseudo-random number generators. It's still
pseudo-random, but "real" randomness generally needs hardware based on some
random physical phenomenon (thermal noise, radioactive decay, etc.)
You should test your system by setting up a simple test harness that runs the
script some large number of times and saving the results. You can then analyse
the results to see if there are any obvious groupings, or whether the
distribution is roughly uniform.
>or is it possible that it needs seeding (although I don't totally understand seeding?
That depends on your PHP version - only older versions need to be explicitly
seeded.
Kevin Williamson wrote:
>>
>>Hi,
I've written a lottery programme in PHP that selects 10 winners a week from approximately 18,000 shares.
The problem I have is that of the ten winners one week the same share number was drawn the next week and an adjacent share number the following week (that just happened to be owned by the same member) The program is now being looked at suspisciously.
The main core of the random draw simply puts all the current share numbers into an array ($currWinner), draws a random number using the rand function between 1 and the number of shares ($lottshares) and returns the share id number.
for the random element ofthe program I use:
$currWinner = rand(1,$lottShares);
is this random enough? or is it possible that it needs seeding (although I don't totally understand seeding?
Any help will be appreciated.
thanks Kevin
Kevin,
Yes, I admit that does look suspicious! Of course, it's always possible for it to happen, but the when you're drawing 10 out of 18K are much against it :-)
Which version of PHP are you running? The reason I asked, versions before 4.2 did not automatically seed the random number generator - you need to do it. See srand().
Version 4.2 and later do this automatically if the generator hasn't been seeded.
Thanks Jerry,
I'm not sure what version of PHP because I installed it on an intranet
and unless I visit the company do not have access to check.
I have had the guy send me the relevant file that contains the draw
sequence to have a look at. I think I'll use srand as a matter of course
and return the updated version...but I agree ... look suspect
thanks again
Kevin
Jerry Stuckle wrote:
>Kevin Williamson wrote:
(Top posting fixed)
Just a suggestion - you should always know what version of PHP is being
used. There are just too many differences, bug fixes, etc. to not. And
phpinfo() is your friend.
Knowing the version would have helped you get to the page in the docs
which would have told you to use srand() if you're below PHP 4.2. Or,
if you're at 4.2+, you need to look elsewhere.
Also, please don't top post.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attglobal.net
==================
In message <Wh******************@newsfe7-gui.ntli.net>
Kevin Williamson <ke***************@ntlworld.comwrote:
>Thanks Jerry,
I'm not sure what version of PHP because I installed it on an intranet and unless I visit the company do not have access to check.
I have had the guy send me the relevant file that contains the draw sequence to have a look at. I think I'll use srand as a matter of course and return the updated version...but I agree ... look suspect
thanks again
Kevin
[snip]
Just create a php file with the following commands
<?php
phpinfo();
?>
That will tell you what version of php you are running amongst other
things.
--
Kev Wells http://kevsoft.topcities.com http://kevsoft.co.uk/
ICQ 238580561
Nor shall my sword sleep in my hand.
On Sat, 11 Nov 2006 11:16:06 +0000, Kevin Williamson wrote:
I'm not sure what version of PHP because I installed it on an intranet
and unless I visit the company do not have access to check.
$ php -r 'phpinfo();'|grep "PHP Version"
PHP Version =5.2.0
-- http://www.mladen-gogala.com
thanks Kevin, I know about phpinfo(). its just that I haven't got access
to their server to run it.
I've now used mt_srand() and mt_rand for my test bed and will run a
check using these.
thanks
Kevin
Kevin Wells wrote:
In message <Wh******************@newsfe7-gui.ntli.net>
Kevin Williamson <ke***************@ntlworld.comwrote:
>Thanks Jerry,
I'm not sure what version of PHP because I installed it on an intranet and unless I visit the company do not have access to check.
I have had the guy send me the relevant file that contains the draw sequence to have a look at. I think I'll use srand as a matter of course and return the updated version...but I agree ... look suspect
thanks again
Kevin
[snip]
Just create a php file with the following commands
<?php
phpinfo();
?>
That will tell you what version of php you are running amongst other
things.
thanks Mladen, I know about phpinfo(). its just that I haven't got
access to their server to run it.
I've now used mt_srand() and mt_rand for my test bed and will run a
check using these.
thanks
Kevin
Mladen Gogala wrote:
On Sat, 11 Nov 2006 11:16:06 +0000, Kevin Williamson wrote:
>I'm not sure what version of PHP because I installed it on an intranet and unless I visit the company do not have access to check.
$ php -r 'phpinfo();'|grep "PHP Version"
PHP Version =5.2.0
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Paul Rubin |
last post by:
http://www.nightsong.com/phr/python/sharandom.c
This is intended to be less predicable/have fewer correlations than
the default Mersenne Twister or Wichmann-Hill generators. Comments
are...
|
by: moi |
last post by:
hi, i have an assignment to put 6 pseudo random numbers into an array to
simulate drawing 6 lottery numbers between 1-49. the code i have to do this
so far is listed below. i dont think its far...
|
by: alanbe |
last post by:
Greetings
I am making a flashcard type application to help me in my TCP/IP
protocols test.
My instructor will test us periodically on how a device or networking
function relates to the OSI...
|
by: BOOGIEMAN |
last post by:
//Why this doesn't work :
using System;
using System.Threading;
class RandomObjectDemo
{
public static void Main( )
{
Thread.Sleep( 1 );
|
by: Milsnips |
last post by:
hi there,
i'm after a small function that is kindof like the lottery picker programs,
i pass it some numbers, say (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15) and i want
it to return me 3 random...
|
by: Anthony |
last post by:
For Some reason, i get the same value everytime...
Ive tested the RND Function with msgboxes and labels, they all have no
influence on the RND Function...
It still doesnt work...
Private Sub...
|
by: NTL Newsgroups |
last post by:
Hi,
I've written a lottery programme in PHP that selects 10 winners a week
from approximately 18,000 shares.
The problem I have is that of the ten winners one week the same share
number was...
|
by: um33 |
last post by:
Hello guys,
I am knew to the VB6 and I do need to wrie a program that generate 6 lottery numbers in ascending Order and Non repeating as well.
Thanks
|
by: Miktor |
last post by:
I'm trying to write a lottery number generator for the uk national
lottery.
Any clues where I'm going wrong?
#include <cstdlib>
#include <iostream>
using namespace std;
int main ()
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: erikbower65 |
last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps:
1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal.
2. Connect to...
|
by: linyimin |
last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
|
by: kcodez |
last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: DJRhino1175 |
last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this -
If...
|
by: lllomh |
last post by:
How does React native implement an English player?
|
by: Mushico |
last post by:
How to calculate date of retirement from date of birth
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
| |