Dwayne,
Point well taken. The described "method of randomness" certainly has
biases that make it less than truly random and, to the best of my
knowledge, all "random number generators" really have those things. (
Which is the primary reason I tried to deal with that portion of the
question separately, and first. :)
You could do something like you described...
However:
That "re-sort" is not really an option (via workflow) if your
only using a display only field as a column in the table. (Well, I do
not know how to do it. Really to bad that there is not a
PERFORM-ACTION-TABLE-SORT [[<fieldID>;<fieldID>;<fieldID>;] |
[col_number;col_number;col_number;]| "null for defined sort order"]
type special process.) You could choose to push those numbers into the
underlying data records(one per record to be updated) but there are
some "client <--> ARS server <--> RDBMS" traffic to deal with too and
the filters to update all those data rows. And the uesr would need to
be able to modify those rows too. Then the table field needs to have
the sort order set the "right way" and you do not want your users
messing with it either. (Or maybe you do not care and can consider
that "yet another" degree of "randomness" too. :)
Also if the user asks for 10 records from a table field of 1000
rows. There really is no need to create 1000 random numbers. You just
need 10.
However, instead of making 100's of calls to create 100's of Random
numbers(some of which you will not use) it might be better to create
"n" random numbers and guard against using the same "random number"
twice too. (Keep track of the random numbers that you get in a display
only field with a separator between the numbers, and only use the
newly generated number if it does not exist in the list already.)
Selecting each randomly selected row (by number) in the table as a
new number is generated and accepted. Then you can walk the table once
based on the "Selected rows" table walk too.
That would be good option and would produce a slightly more "random"
distribution. It would only cost you the network traffic and RDBMs
time of generating the "random" numbers from your RDBMS and could save
you walking the table a few times. (Which if the number of rows is
large, will cost you something too.)
If the added cost is worth the improved "randomness" then it might be
a good direction to head in.
Thanks for the suggestion.
Do you know if other RDBM's that ARS supports has similar random
number generator features?
--
Carey Matthew Black
Remedy Skilled Professional (RSP)
ARS = Action Request System(Remedy)
Solution = People + Process + Tools
Fast, Accurate, Cheap.... Pick two.
Never ascribe to malice, that which can be explained by incompetence.
On 8/15/06, Dwayne Martin <[EMAIL PROTECTED]> wrote:
In Oracle the equation:
select trunc(DBMS_RANDOM.value(0,1000)) from dual
gives you a random number of 1 - 999.
If you are looping a table, the entries in the top of the
table have a slightly better chance of getting picked than
those on the bottom. Eg, if you find enuf entries before you
get to the bottom, those on the bottom don't have any chance.
If you get to the bottom and start over those at the top get
two chances, but those at the bottom only get one, etc.
Depending on how important this is, you could use your random
process to go thru and give each entry a random sort number,
then sort your table by this number, and select however many
you want from the top.
Dwayne Martin
James Madison University
---- Original message ----
>Date: Mon, 14 Aug 2006 11:49:45 -0400
>From: Carey Matthew Black <[EMAIL PROTECTED]>
>Subject: Re: How to random get 100 entries form a table list.
>To: [email protected]
>
>Ok. That is helpful.
>
>The user has on their screen a table field with N rows in it.
And you
>want a way to "select" (randomly) some sub set of those rows.
>
>
>First a discussion about random selection definition then
later a
>"how" to do this in the ARS clients.
>
>Randomly could be used as follows:
>
>When the user specifies the "number" they want to audit, you
could use
>the last digit of the "seconds" to be a "random seed" to the
selection
>process. Let us call that number "now_single_second". Keep
that in a
>temp field.
>
>Then loop over the table and grab the records that have a
modified
>date that ends in that same digit until you reach the
"number" they
>wanted.
>
>If you finish that pass through the table and still do not
have enough
>records, then loop through the table and grab every record
that is the
>"now_single_second" record in the table.
>
>If you finish that pass through the table and still do not
have enough
>records, then reset "now_single_second" (or just add/subtract
one to
>the existing value) and loop through the table and grab every
record
>that is the "now_single_second" record in the table.
>
>
>
>How to do it in the clients.
>
>Add a column to the table field that uses a "Display only
field" from
>the local form. When looping through the table and you
"select" a row
>set this columns value to "X". You can then use the COLCOUNT()
>function to count the rows that are selected throughout the
process.
>
>
>Once you have all the rows marked in the display only field
then those
>rows can be later selected by using the "ROWCHANGED" keyword
when you
>walk the table again to do whatever the system/user needs to
do for
>those records.
>
>I hope that gives you some ideas...
>
>Just note that if the table field is refreshed that these "X"
values
>will be cleared, so do not do that. :)
>
>
>--
>Carey Matthew Black
>Remedy Skilled Professional (RSP)
>ARS = Action Request System(Remedy)
>
>Solution = People + Process + Tools
>Fast, Accurate, Cheap.... Pick two.
>Never ascribe to malice, that which can be explained by
incompetence.
On 8/14/06, 李坤 <[EMAIL PROTECTED]> wrote:
>
>
> ARSLISTDear Listers,
>
> I am sorry to trouble you,there is some question with my
work.
> How to random get 100 entry form a table list.
>
> Thanks a lot !
>
>
>
> [EMAIL PROTECTED]
_______________________________________________________________________________
UNSUBSCRIBE or access ARSlist Archives at http://www.wwrug.org