Newbies Montessori FM Pro Posted March 22, 2007 Newbies Posted March 22, 2007 I've been using FileMaker for the past 3 years to generate a random number for lottery applicants to our charter school. It has worked really well for that purpose. Problem I keep having is that as our application pool grows bigger, so does my occurance of repeating "random numbers". I can't figure out how to make the random numbers discrete, so that it doesn't look as though we've rigged the results. Calculation I'm using for the number is Int(Random*10) & Int(Random*10) & Int(Random*10) Is there something I can add to that to make the resulting 3 digit number unable to repeat, or is there something else I need to define elsewhere? Thanks......
Ender Posted March 22, 2007 Posted March 22, 2007 Another way to approach this would be to have a file/table with 999 (1000?) records numbered sequentially, with a calc to format the serial number with padded 0's, and a field to flag the used numbers. Then have a script Find records that haven't been marked, and use the Random function to choose a random record in the found set.
comment Posted March 22, 2007 Posted March 22, 2007 I think you can do without the table (unless you need it for tracking the ticket sales, or something), and use simply: Int ( random * n ) + 1 where n is the number of tickets (starting from ticket #1). This can be padded with leading zeros, if so desired. Is there something I can add to that to make the resulting 3 digit number unable to repeat Yes - but THAT would be rigging the results. Random is random, and random numbers do repeat - at random...
Newbies Montessori FM Pro Posted March 23, 2007 Author Newbies Posted March 23, 2007 (edited) I don't think I explained well. This is the equivalent of pulling children's names out of a hat for a limited number of spots in the school. We assign everyone a number (randomly) and then order the numbers to determine who gets in, and the order of the subsequent waitlist. If I have two kids who both draw 101, for example, I have a problem. The last two years it's happened, but the numbers were high so the kids were down the waitlist. We do this in public and invite the public (nobody has ever showed up), but basically we create the database while people are watching. The paper applications are ordered alphabetically, and then as I create a new record for a new name, the random "lottery number" is created in the field. Then we sort by grade and lottery number, print and certify the results. It seems that what you are suggesting is to have a set of "prenumbered" records available that I enter the data in (and that come up in random order), rather than creating a new record for each name as I go along. Have I got that right? Edited March 23, 2007 by Guest
comment Posted March 23, 2007 Posted March 23, 2007 There are many ways to do this. For example, you could just enter everyone into a list (in any order), then draw the winner by script (the script goes to a random record, sets a field to "winner"). Then omit the winning record, and repeat the process to draw the first runner up, and so on. Using Status(CurrentFoundCount) as n in the formula above will assure there will be a 'winner' in each round. Alternatively, you could continue with the current method, but check (again, by a script) if the random number has been already assigned, for example (untested) Loop Set Field [ LotNumber ; Random ] Exit Loop If [ not SameNumber::LotNumber] End Loop where SameNumber is a self-join based on LotNumber.
Recommended Posts
This topic is 6515 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now