Re: random numbers
Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance
On Fri, 06 Jul 2007 17:45:58 GMT, Phil Hellmuth <billort@xxxxxxxxxxx> wrote:
I want to pull a group of random numbers within a certain range, but
don't want to check after each grab whether I've previously pulled the
number. For example, let's say I want to generate three random numbers
between 1 and 100. I'll store the numbers in an array. Can I do this
without having to search through the array each time I generate a new
number to ensure I haven't already pulled the number?
Thanks in advance.
As Steve says, that's not really a random selection; it's a random *ordering*
("select without replacement" in statistics jargon. You can get the effect by
having a table of your random numbers and shuffling it, sorting the records by
a random value. You can store them in a table and have some field (yes/no
perhaps) indicating which ones you've already selected.
John W. Vinson [MVP]
.
Relevant Pages
- random numbers
... I want to pull a group of random numbers within a certain range, but don't want to check after each grab whether I've previously pulled the number. ... I'll store the numbers in an array. ... Can I do this without having to search through the array each time I generate a new number to ensure I haven't already pulled the number? ... (microsoft.public.access.modulesdaovba) - Storing RegExp matches in an array
... given a file with a variable number of lines I want to grab lines that ... match a regexp and store the matches in an array such that the results ... (perl.beginners) - Re: Finding the nearest match without reusing results
... comparing an array with a value generates an array of Trues and ... Any diff with wrong State or with used Store is implicitly zeroed out. ... Each must be larger than the absolute value of the maximum Sales ... go.....it just needs to return the closest match. ... (microsoft.public.excel.programming) - Re: read keyboard input and storing in an array?
... > I'm trying to store user input in an array, ... You have the beginnings of that logic already since your prompt tells the ... 201st value since the array only has room for 200 values. ... This will force you to store the int values as Integer ('Integer' ... (comp.lang.java.help) - Re: Challenge: reading ascii data
... to store all the data before producing any output. ... would be bad practice in terms of memory consumption to use a standard ... So I use hashes to create a two-level "sparse array", ... Well the original problem definition was: ... (comp.lang.fortran) |
|