Re: Using the random function

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



To have a random number, use Rnd().

In a query, that will be 'optimized' as being a 'constant', meaning it is
recognize to NOT depend on any field of any tables. So, it will be computed
only ONCE, at the beginning of the query execution. To have it executed for
each row, use a numeric field as argument: Rnd( fieldName )

To have a pick without duplicated values, that depends on how many out of
many you pick, and if the picking is ordered, or not. As example, to pick
two cards, in order, in a play a 52 cards won't use the same strategy than
to pick the all the 52 cards, in order. In the last case, someone can take a
sequence of 52 random numbers and then, find their ranks: get the order of
picking each card accordingly to the rank value of each random number:

Card RandomValue Rank
1-Spade 0.000456 3
2-Spade 0.956958 51
....

so, the Ace of spade will the be third card to be picked, while the two of
space will be the before last one of the stack. The rank is computed from
the randomValue values. The rank of 3 assumes that 0.000456 is the third
smallest random value in the set of 52 random values we got. The rank of 51
assumes that 0.956958 is the second highest random value in the set.



Hoping it may help,
Vanderghast, Access MVP



"Aaron" <aaronsan@xxxxxxx> wrote in message
news:1192544017.736405.263640@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi all...first post in about a year, but you all (on other access ngs)
were so helpful last time I couldn't imagine not asking for help
again!

I am trying to write a query that populates several lists (of certain
lengths, which I already have produced) with one field that is
randomly generated from a larger list of a very similar type.
Basically, I am predicting future data based on several years of
historical data. I would like the field in question, call it
"Response", to be a random selection from the "Response" field of
those multiple years (in one table).

I am populating a list of about 2,000, from a list of about 16,000, so
I think I can choose random numbers WITH replacement (makes it easier,
right?), but if you would still recommend choosing without
replacement, please let me know how to do that.

At any rate, I want to randomly choose one of the 16,000 Responses
(they are integers) as the entry for each "Response" in the new,
predicted, list of 2,000.

My preferred way of solving this would be to use a query in design
mode. I was hoping I could do this without coding.

For the table names, call the list of 2,000 "2006", and the list of
16,000 "Allyears".

Thank you!

-Aaron



.



Relevant Pages

  • Re: Using the random function
    ... Public Function DoRandomize() AS long ... and, in the query, use: ... two cards, in order, in a play a 52 cards won't use the same strategy ... The rank is computed from ...
    (microsoft.public.access.queries)
  • Re: Using the random function
    ... In a query, that will be 'optimized' as being a 'constant', meaning it is ... two cards, in order, in a play a 52 cards won't use the same strategy than ... so, the Ace of spade will the be third card to be picked, while the two of ... The rank is computed from ...
    (microsoft.public.access.queries)
  • Re: how to create item numbers column in a Query Options
    ... free from any other fields in the Query. ... Because, rank numbers will be ... how would YOU assign a rank order to correctly sort the cards? ...
    (microsoft.public.access.queries)
  • RE: Weird Problem with a Subreport
    ... Ok for the sorting i will try to explain it to you. ... query by writing the SQL I didnt include the Place holder field, ... Do you have a text box in the Goup Header? ... I have a header of shutdown in front of the whole list but the two lists ...
    (microsoft.public.access.reports)
  • RE: Weird Problem with a Subreport
    ... Now I need to make reports for the lists for all ... a save as for the reports and just change which query they are getting the ... and used sorting and grouping to sort by the placeholder and all is well!!!! ... Do you have a text box in the Goup Header? ...
    (microsoft.public.access.reports)