rivet Posted February 16, 2005 Posted February 16, 2005 I have a simple table of name that I would like to create a random draw of 35 non-repetative names, where would I start with this?
RalphL Posted February 16, 2005 Posted February 16, 2005 Start by adding a number field Position. Use replace to fill it will a serial number. In a script make a loop that starts with the first position, gets a random number between 1 and the number of records. Exchange position numbers between these records. Go to position 2 and repeat the above. Continue until you have exchanged the last position. Sort by position. Use the first 35. You can repeat the process several times to get more changes to the order.
comment Posted February 16, 2005 Posted February 16, 2005 Create a calculation field, cRandom = Random (result Number, unstored). Show all records. Sort by cRandom. Go to Record 36. Omit Multiple Records [ Get ( FoundCount ) - 35 ].
Oldfogey Posted February 17, 2005 Posted February 17, 2005 Rivet, Do you mean 35 random, unique names? Do the names have to be real names, such as Bob, Peter, etc. or can they be Glbb, Pkz, etc.?
rivet Posted February 18, 2005 Author Posted February 18, 2005 they need to be names pulled from a table of names. Thinking about it now, I am going to try a script that will loop, do a find on a number in the 'found count' if that record has been tagged, skip, else tag.
RalphL Posted February 18, 2005 Posted February 18, 2005 Take a look at the sample file that does what I had suggested earlier. It has 2 scripts one which will set the order number in sequence, the other which will randomize it. You can repeat the second several times to get more mixing. Sort of like shuffling a deck of cards.
Oldfogey Posted February 18, 2005 Posted February 18, 2005 Ralph, I can't read your attachment cos it's .sit but rivet is after a card hand, not a shuffled deck. Rivet, If your table of names is in a table separate from your selected subset, then 1. Number your names (auto serial will do) Say N names. 2. Select a random number between 1 and N 3. Copy that name and serial into your table 4. (3.5) Define a self-join on serial 5. If Count(SelfJoin::serial) > 1 delete it and get another one.
RalphL Posted February 18, 2005 Posted February 18, 2005 You need a copy of Stuffit expander for Windows, it used to be free, I haven't checked recently. Works with all sorts of compressions. You shuffle the cards before you deal the hand. I can send you a .zip if you are interested.
Oldfogey Posted February 20, 2005 Posted February 20, 2005 Ralph, Thanks. I'll check out the Windoze version. (No need to waste your time on my abysmal ignorance.) I just love the way so many of these posts descend into arguments/discussions/duels/.. about what the original poster was looking for. The really beaut thing is that rarely does the OP join in! This time he has and I'm going to have a look when I sober up in a minute or two. (It's real time here - about 00.07)
Oldfogey Posted February 21, 2005 Posted February 21, 2005 Rivet, Sorry to be so long. A network break and a paying job intervened. I like your solution. Neat. Why did you add 1 to the FoundCount? You do not need to cater for the extremes of Random (0 and 1). Go to Record [Value] takes you to record 1 or the last record, if the Value is outside the valid range. You do realise that your set is not, mathematically speaking, truly random?
rivet Posted February 24, 2005 Author Posted February 24, 2005 thanks I will fix the 1. and what do you mean not entirely random? You are scaring me.
Oldfogey Posted February 24, 2005 Posted February 24, 2005 Rivet, I thought I'd posted this already. Must be gremlins. Like your script! Why are you adding 1 to your random number? 'Go To Record[by number]' takes you to the first or last record if the number is out of range.
RalphL Posted February 24, 2005 Posted February 24, 2005 The way radom numbers are generated is not truly random. Each number in the series is dependent on a seed number. The seed may be generated from the date, the time, the computer's id, and even the preceeding random number. I don't think you have anything to worry about.
Recommended Posts
This topic is 7212 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