Limiting Random Choices from a Table
Hi All,
I have a table with a wordlist of ~ 1000 words.
Each word is on its own row, and for this example, we'll say that each row has 4 properties (columns), set up as boolean values as to whether or not the word is:
1) longer than 5 letters
2) begins with a vowel
3) has two syllables
4) starts with a consonant
I have an index attribute, set to change attribute to a random number corresponding to a word in the table.
For the sake of argument, let's say that I want it to choose a random number (corresponding to a word) that is longer than 5 letters (boolean option 1).
The way I have it set right now, is that ANY random number is chosen, and then I check to see if it fits the criteria, and if it doesn't, I choose another random number, and recheck, and so on... looping until the criteria for option 1 is met.
The problem is that this process of changing to ANY random number, and then checking to see if it fits will take quite a long time, and I ultimately anticipate having much more than 1000 words in my table, and many more properties (boolean criteria).
I tested the amount of time it took to generate a value of 50 from a randomnumber between 1-100, and it was about 5 seconds, which is too long for my purposes.
My question is: Is there a way for me to choose the random number from the list of words that already fits the criteria of option 1 (instead of choosing ANY random number and THEN checking to see if it fits)? I would like to have just the one giant table setup, instead of multiple tables if possible. But it seems that the randomization process would be much faster if I could first limit the random option to only words that fit the criteria.
Any thoughts/suggestions are appreciated.
I have a table with a wordlist of ~ 1000 words.
Each word is on its own row, and for this example, we'll say that each row has 4 properties (columns), set up as boolean values as to whether or not the word is:
1) longer than 5 letters
2) begins with a vowel
3) has two syllables
4) starts with a consonant
I have an index attribute, set to change attribute to a random number corresponding to a word in the table.
For the sake of argument, let's say that I want it to choose a random number (corresponding to a word) that is longer than 5 letters (boolean option 1).
The way I have it set right now, is that ANY random number is chosen, and then I check to see if it fits the criteria, and if it doesn't, I choose another random number, and recheck, and so on... looping until the criteria for option 1 is met.
The problem is that this process of changing to ANY random number, and then checking to see if it fits will take quite a long time, and I ultimately anticipate having much more than 1000 words in my table, and many more properties (boolean criteria).
I tested the amount of time it took to generate a value of 50 from a randomnumber between 1-100, and it was about 5 seconds, which is too long for my purposes.
My question is: Is there a way for me to choose the random number from the list of words that already fits the criteria of option 1 (instead of choosing ANY random number and THEN checking to see if it fits)? I would like to have just the one giant table setup, instead of multiple tables if possible. But it seems that the randomization process would be much faster if I could first limit the random option to only words that fit the criteria.
Any thoughts/suggestions are appreciated.
Comments