The code I posted last week showing how to randomize Chars for passwords could give you a varying string of numbers from 0 to 9 (as text) or with some modification give you varying strings of two or three digit numbers of an indeterminate length.
When I used 8 characters, the algorithm produced only 1 repeat in two hundred iterations, so it isn't too bad. And it is still an All RBase solution.. ----- Original Message ----- From: "Michael Sinclair" <[EMAIL PROTECTED]> To: "RBASE-L Mailing List" <[email protected]> Sent: Wednesday, April 09, 2008 2:53 PM Subject: [RBASE-L] - RE: [SPAM] [RBASE-L] - Re: [SPAM] [RBASE-L] - Randomnumbers > Could you generate a list of random numbers, perhaps 10,000 numbers, store > them in a table, and use the table as your source of random numbers? You > could easily put in an extra column to keep track of where you left off so > that you would not see the same sequence for a long time. > Mike > > Marc wrote: >> Hi Steve >> >> 1) I may have 10 to 20 rows of data with phrases. I count the number >> of rows then make the Random function statement to pick one of >> the rows / phrases at random. Each user can have as many or as >> little rows of data as they like. >> 2) It seems each time I restarted Rbase it would pick the same sequence >> of numbers such as 0 0 5 0 5 3 8 2 10 14 , then restart and the same >> Random statement would give the same numbers. If I did not close >> Rbase then the numbers kept going and seemed to be random. >> >> One thing I did not test is we get in and out of this form and have >> different >> categories of phrases, so the Random statement may be set to 5 or 10 or 20 >> for any given office depending on the category they are trying to get a >> random >> phrase for. So, since the Random statement is not exactly the same the >> numbers >> may not be very random. I really have not checked this yet. >> >> I do not need 100% random numbers and a few repeats is OK. But if I use >> this >> form 20 times a day and sometimes I am doing Random for x rows then Random >> for >> y rows, then Random for x .... I would not want the same set of numbers like >> the >> above example 0 0 5 0 5 3 8 2 10 14 . Because I would keep geting 0 each >> time that >> Randon for x was run. >> >> I hope that makes sense, again I need to test it further with this new >> variable included. >> >> Thanks >> Marc >> >> >> >> >> >> >> Marc, couple of Q's: >> (1) How many of these text items/phrases exist and are they identified >> by some sort of numeric? >> (2) I still don't understand your perspective that "... RBase ... >> remembers where it left off ...". Could you elaborate on that? >> >> Now, let me try somethin' out on you. Let's say that you have 15 items >> - I take that from your RANDOM(15) example - and that they are >> identified numerically from 1 thru 15. If so, then perhaps something >> along the lines of the command-file below would meet your needs. Again, >> I cannot say, Y||N, if the results are "precisely" random; of course, I >> cannot precisely define "random", either, at least in a rock-solid >> statistical/mathematical sense. I do know that there exists one-or-more >> statistical tests to verify something like this. >> >> However, to my eyeball-test, it appears random, despite the occasional >> sets of repeated values which might give one pause. Still, no number >> repeats more than twice. Were we to loop it 1000x rather than 100, >> then, I think, our odds of getting 3 of the same values in a row should >> increase, but, to be honest, I don't know if I could have determined by >> how much even when I was studying business/management statistics. >> >> However, I do know that the probability of a series of independent >> events is pretty simply calculated by multiplying the probability of a >> single event by the number in the series, i.e. P(A1,A2,A3) = P(A1) * >> P(A2) * P(A3), where A is the generation of that random number and 1,2,3 >> are iterations 1..3. In our case, RBase tells us: >> >> R>SET VAR vProbability03 REAL=((1/15) * (1/15) * (1/15)) >> >> R>sho var >> Variable = Value Type >> ------------------ ------------------------------ -------- >> #DATE = 04/09/2008 DATE >> #TIME = 10:41:14.695 TIME >> #PI = 3.14159265358979 DOUBLE >> SQLCODE = 0 INTEGER >> SQLSTATE = 42S02 TEXT >> #NOW = 04/09/2008 10:41:14.787 DATETIME >> vProbability03 = 0.0002963 REAL >> >> >> I do think that probability goes up with the number of iterations. >> However, I think it remains sufficiently low. Again, that's beyond what >> I currently grasp. This site, http://mathforum.org/dr.math/ask/, has >> some pretty good stuff, if anybody's interested, and I'm sure there are >> more. >> >> The point of all this is, that I ain't so sure that RB's RANDOM() >> function has any faults. I really think it works as advertised. I >> think it comes down to how we utilize it, including what we pass to it >> and what we do with the value returned from it. Albert's example is a >> nice variation on doing something with what we pass to it. I hope my >> use of MOD(.vAlbertsNUM,IntegerOfPossibleOutcomes) >> illustrates a variation on doing something with the return value. >> >> Now, let me ask/add, if any repeating series is "verboten", i.e. no >> number can occur more than one at a time, then you could add another >> WHILE-loop to trap for this, as shown next, between the long >> asterisked-lines. This block will loop anytime the number, >> vWhichTextToGet, repeats. So, there will never be a series of numbers >> longer than 1. Truly, although this approach seems to nicely pass the >> "eyeball test", I suspect that, mathematically/scientifically, it's >> actually "less" random ... >> >> -- **************************** >> -- *** RandomTextTestxA.RMD *** >> -- **************************** >> ... >> -- *** Init var to help trap repeaters ... *** >> SET VAR vWhichTextToGetPREV INT = 0 >> ... >> WHILE ... >> -- ****************************************************** >> -- *** Is the current value the same as the previous? *** >> -- *** This will always be true the first iteration *** >> -- *** as they are both zero *** >> WHILE vWhichTextToGetPREV = .vWhichTextToGet THEN >> -- *** Albert's expression ; check your quote settings ...*** >> SET VAR vAlbertsNUM INT=(RANDOM(INT(1000 * >> (FLOAT(FORMAT(.#time,'hhmmss.sss')))))) >> >> -- *** Assign value to determine which item to select from table >> ************ >> -- *** 15 is the value because it is the count of our RandomText >> records *** >> -- *** Since result of MOD() can be 0..14, add one to make it >> 1..15, *** >> -- *** as 15 is our "sample space", possible outcomes, or solution >> domain *** >> SET VAR vWhichTextToGet = ((MOD(.vAlbertsNUM,15)) + 1) >> >> ENDWHILE >> >> -- *** Assign value to duplicate test var *** >> SET VAR vWhichTextToGetPREV = .vWhichTextToGet >> -- ****************************************************** >> ... >> ENDWHILE >> ... >> RETURN >> >> >> >> Well, not to beat a dead horse, but "Hi, ho, Silver, away!" >> Steve in Memphis >> >> >> >> -- **************************** >> -- *** RandomTextTestxA.RMD *** >> -- **************************** >> >> SET VAR vWhichTextToGet INT=0 >> SET VAR vCounter INT=0 >> >> WHILE vCounter < 100 THEN >> >> -- *** Albert's expression ; check your quote settings ...*** >> SET VAR vAlbertsNUM INT=(RANDOM(INT(1000 * >> (FLOAT(FORMAT(.#time,'hhmmss.sss')))))) >> >> -- *** Assign value to determine which item to select from table >> ************ >> -- *** 15 is the value because it is the count of our RandomText >> records *** >> -- *** Since result of MOD() can be 0..14, add one to make it 1..15, >> *** >> -- *** as 15 is our "sample space", possible outcomes, or solution >> domain *** >> SET VAR vWhichTextToGet = ((MOD(.vAlbertsNUM,15)) + 1) >> >> -- *** See what ya' got there ************************************ >> -- *** In my simple table, I used the numbers 1..15 for ID's *** >> -- *** and the name of that number for the text, like NUM2Word *** >> SELECT .vCounter, .vAlbertsNUM, .vWhichTextToGet, RandomText, + >> FROM RANDOM_TEXT_TBL + >> WHERE RandomTextID = .vWhichTextToGet >> >> -- *** Just for appearance during testing, after first SELECT *** >> SET HEADINGS off >> >> -- *** Use something like this to SELECT the RandomText INTO a var >> *** >> { >> SELECT RandomText INTO vRandomText IND viRandomText + >> FROM MY_RANDOM_TEXT_TBL + >> WHERE RandomTextID = .vWhichTextToGet >> } >> >> -- *** Increment counter >> SET VAR vCounter = (.vCounter + 1) >> >> ENDWHILE >> >> -- *** Reset headings >> SET HEADINGS on >> >> RETURN >> >> >> R>run spRandomTextTestxA.RMD >> 0 5976443 9 RandomText >> ---------- ---------- ---------- ------------------------ 0 >> 5976443 9 Nine >> 1 73764218 9 Nine >> 2 54736378 14 Fourteen >> 3 86170466 12 Twelve >> 4 71083348 14 Fourteen >> 5 9630739 5 Five >> 6 63371555 6 Six >> 7 82733176 2 Two >> 8 8318094 10 Ten >> 9 14836858 14 Fourteen >> 10 7375324 5 Five >> 11 62039506 2 Two >> 12 36737584 5 Five >> 13 22929708 4 Four >> 14 46234866 7 Seven >> 15 11494059 10 Ten >> 16 47519728 14 Fourteen >> 17 901058 9 Nine >> 18 25827580 11 Eleven >> 19 28052423 9 Nine >> 20 20932946 12 Twelve >> 21 69228632 3 Three >> 22 14027609 15 Fifteen >> 23 27557416 2 Two >> 24 73266756 7 Seven >> 25 56107688 9 Nine >> 26 9199715 6 Six >> 27 88609858 14 Fourteen >> 28 51146324 15 Fifteen >> 29 32187899 15 Fifteen >> 30 37580366 12 Twelve >> 31 83932191 7 Seven >> 32 3137028 4 Four >> 33 45993076 2 Two >> 34 78564800 6 Six >> 35 31715155 11 Eleven >> 36 79132163 9 Nine >> 37 59564663 9 Nine >> 38 31459319 15 Fifteen >> 39 2155319 15 Fifteen >> 40 2736561 7 Seven >> 41 35934060 1 One >> 42 73965057 13 Thirteen >> 43 9230337 13 Thirteen >> 44 38940407 3 Three >> 45 84433007 3 Three >> 46 76837942 8 Eight >> 47 89895040 11 Eleven >> 48 48220837 8 Eight >> 49 68672782 8 Eight >> 50 65232620 6 Six >> 51 89416762 8 Eight >> 52 7475500 11 Eleven >> 53 41259878 9 Nine >> 54 26720475 1 One >> 55 84079964 15 Fifteen >> 56 46963867 8 Eight >> 57 89914673 9 Nine >> 58 54044483 9 Nine >> 59 48696500 6 Six >> 60 11897410 11 Eleven >> 61 47798232 13 Thirteen >> 62 33859521 7 Seven >> 63 64665439 5 Five >> 64 60752484 10 Ten >> 65 22017738 4 Four >> 66 51872545 11 Eleven >> 67 40520219 15 Fifteen >> 68 30703042 8 Eight >> 69 6054396 7 Seven >> 70 87617733 4 Four >> 71 58455404 15 Fifteen >> 72 84725450 6 Six >> 73 76885613 9 Nine >> 74 78214981 2 Two >> 75 45392731 2 Two >> 76 6176772 13 Thirteen >> 77 80356453 14 Fourteen >> 78 17896237 8 Eight >> 79 64351378 14 Fourteen >> 80 19973710 11 Eleven >> 81 32282772 13 Thirteen >> 82 79071673 14 Fourteen >> 83 15754822 8 Eight >> 84 50507216 12 Twelve >> 85 47684427 13 Thirteen >> 86 57215205 1 One >> 87 44483419 5 Five >> 88 22028960 6 Six >> 89 23158085 6 Six >> 90 39071453 9 Nine >> 91 77811971 12 Twelve >> 92 25371841 2 Two >> 93 71949472 8 Eight >> 94 47245095 1 One >> 95 63364283 9 Nine >> 96 40589974 5 Five >> 97 22996820 6 Six >> 98 13880414 15 Fifteen >> 99 61303552 8 Eight >> >> >> >> -----Original Message----- >> From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Marc >> Sent: Wednesday, April 09, 2008 1:27 AM >> To: RBASE-L Mailing List >> Subject: [SPAM] [RBASE-L] - Re: [SPAM] [RBASE-L] - Random numbers >> Importance: Low >> >> Thanks Albert >> >> But I do not think that will work for me. >> I use the random number to get a row number. >> I have a table with dozens of sample text for form letters >> and I want to select them at Random. >> >> I think the Random function will work OK, as long as they >> do not restart Rbase several times a day. It seems as long >> as RBase is on it remembers where it left off so to speak >> then picks another random number but is you restart RBase >> it starts over with the same sequence of numbers. >> >> So, I think this will work, I never really tested it until now. >> >> Thanks >> Marc >> >> >> >> >> ----- Original Message ----- From: "Albert Berry" <[EMAIL PROTECTED]> >> To: "RBASE-L Mailing List" <[email protected]> >> Sent: Tuesday, April 08, 2008 12:11 PM >> Subject: [RBASE-L] - Re: [SPAM] [RBASE-L] - Random numbers >> >> >>> R:Base uses a pseudo random number generator. You can use the system >>> time variable to the 1/1,000 second to generate pseudo random numbers >>> that are for all intents and purposes random. Here is an example >>> >>> select (random(INT(1000 * (FLOAT(format(.#time,"hhmmss.sss")))))) from >> >>> sys_tables where count = 1 >>> >>> >>> >>> Marc wrote: >>>> I just tested this 3 times and get the same numbers each time. >>>> I am setting the Random number to 15 and created 10 >>>> The numbers I get are >>>> 0 0 5 0 5 3 8 2 10 14 each of the 3 times I tested this. >>>> >>>> I hope I am missing something, I sent an update out several months >>>> back that needs truley random numbers. >>>> >>>> Marc >>>> >>> >>> >> >> >> >> > > >

