Re: Non-repeating Random Numbers

This WebDNA talk-list message is from

2002


It keeps the original formatting.
numero = 43042
interpreted = N
texte = this is the same logic that says your just as likely to win the lottery three times in a row as not win it at all.unless, your banking on winning it three times in a row then its way way harder.anyway - this is kids stuff - who wants to answer my question about freight and taxes and formula databases and all the other good things in life.----- Original Message ----- From: Dan Strong To: WebCatalog Talk Sent: Monday, September 02, 2002 10:28 AM Subject: Re: Non-repeating Random Numbers > John, > > > > >That's not random, though. A true random number sequence > >can contain a very large run of identical values. > > > > Point taken :) > > Ok, this appears to work: > > [!] --- Generate 6 unique numbers between 1 and 54 --- > [/!] > [text show=f]unique_numbers= [/text] > [math show=f]found=0[/math] > [loop start=1&end=20] > [text show=f]random_number=[math]ceil([RANDOM > format=float]*(54))[/math][/text] > [showif [unique_numbers]! [random_number] ] > [text > show=f]unique_numbers=[unique_numbers][random_number] > [/text] > [math show=f]found=[found]+1[/math] > [/showif] > [showif [found]=5][break][/showif] > [/loop] > [unique_numbers] > > I changed a few thing so I could understand the logic > better, namely: > > 1) I renamed the variables to something more literal that > I could wrap my mind around, and > > 2) I used (The actual space bar) as a delimiter > instead of '+' because '+' was confusing me into thinking > I was doing math at first and also the display of the > final numbers is cleaner with . Seems to work ok > for the time being, but if I want to manhandle the > [unique_numbers] variable later (with [grep] or whatever) > I'll probably have to use a more tangible > delimiter...don't really know yet and I'm just rambling.. > > One question: regarding [loop start=1&end=20]: > Theoretically, the process could loop 20 times in a row > and not generate unique numbers (basically, end=20 could > occur before [found]=5) and if this happened then the loop > would stop without generating 6 numbers, right? Should I > increase this limit to, oh, say 1000 or something to avoid > this (unlikely) scenario? > > Thanks John! > > -Dan > ------------------------------------------- > http://www.StrongGraphicDesign.com > (208) 319-0137 | Toll-free p/f 877-561-1656 > > > > ------------------------------------------------------------- > This message is sent to you because you are subscribed to > the mailing list . > To unsubscribe, E-mail to: > To switch to the DIGEST mode, E-mail to > Web Archive of this list is at: http://search.smithmicro.com/ ------------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://search.smithmicro.com/ Associated Messages, from the most recent to the oldest:

    
  1. Re: Non-repeating Random Numbers - CORRECTION (Dan Strong 2002)
  2. Re: Non-repeating Random Numbers - CORRECTION (Brian Fries 2002)
  3. Re: Non-repeating Random Numbers - CORRECTION (Stuart Tremain 2002)
  4. Re: Non-repeating Random Numbers - CORRECTION (Dan Strong 2002)
  5. Re: Non-repeating Random Numbers - CORRECTION (Stuart Tremain 2002)
  6. Re: Non-repeating Random Numbers - CORRECTION (Andrew Simpson 2002)
  7. Re: Non-repeating Random Numbers - CORRECTION (Andrew Simpson 2002)
  8. Re: Non-repeating Random Numbers (Andrew Simpson 2002)
  9. Re: Non-repeating Random Numbers - CORRECTION (Dan Strong 2002)
  10. Re: Non-repeating Random Numbers - CORRECTION (Dan Strong 2002)
  11. Re: Non-repeating Random Numbers (Dan Strong 2002)
  12. Re: Non-repeating Random Numbers (John Peacock 2002)
  13. Non-repeating Random Numbers (Dan Strong 2002)
this is the same logic that says your just as likely to win the lottery three times in a row as not win it at all.unless, your banking on winning it three times in a row then its way way harder.anyway - this is kids stuff - who wants to answer my question about freight and taxes and formula databases and all the other good things in life.----- Original Message ----- From: Dan Strong To: WebCatalog Talk Sent: Monday, September 02, 2002 10:28 AM Subject: Re: Non-repeating Random Numbers > John, > > > > >That's not random, though. A true random number sequence > >can contain a very large run of identical values. > > > > Point taken :) > > Ok, this appears to work: > > [!] --- Generate 6 unique numbers between 1 and 54 --- > [/!] > [text show=f]unique_numbers= [/text] > [math show=f]found=0[/math] > [loop start=1&end=20] > [text show=f]random_number=[math]ceil([RANDOM > format=float]*(54))[/math][/text] > [showif [unique_numbers]! [random_number] ] > [text > show=f]unique_numbers=[unique_numbers][random_number] > [/text] > [math show=f]found=[found]+1[/math] > [/showif] > [showif [found]=5][break][/showif] > [/loop] > [unique_numbers] > > I changed a few thing so I could understand the logic > better, namely: > > 1) I renamed the variables to something more literal that > I could wrap my mind around, and > > 2) I used (The actual space bar) as a delimiter > instead of '+' because '+' was confusing me into thinking > I was doing math at first and also the display of the > final numbers is cleaner with . Seems to work ok > for the time being, but if I want to manhandle the > [unique_numbers] variable later (with [grep] or whatever) > I'll probably have to use a more tangible > delimiter...don't really know yet and I'm just rambling.. > > One question: regarding [loop start=1&end=20]: > Theoretically, the process could loop 20 times in a row > and not generate unique numbers (basically, end=20 could > occur before [found]=5) and if this happened then the loop > would stop without generating 6 numbers, right? Should I > increase this limit to, oh, say 1000 or something to avoid > this (unlikely) scenario? > > Thanks John! > > -Dan > ------------------------------------------- > http://www.StrongGraphicDesign.com > (208) 319-0137 | Toll-free p/f 877-561-1656 > > > > ------------------------------------------------------------- > This message is sent to you because you are subscribed to > the mailing list . > To unsubscribe, E-mail to: > To switch to the DIGEST mode, E-mail to > Web Archive of this list is at: http://search.smithmicro.com/ ------------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://search.smithmicro.com/ Andrew Simpson

DOWNLOAD WEBDNA NOW!

Top Articles:

Talk List

The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...

Related Readings:

[quantity] solved (1997) Date format problems (1997) Emailer setup (1997) Likelihood of a duplicate (2005) Date search - yes or no (1997) Running 2 two WebCatalog.acgi's (1996) Shopping carts and reloading pages (1997) Problems passing [SKU] with $Replace in 2.0 (1997) Pithy questions on webcommerce & siteedit (1997) wrong input values? (1997) SMSI: Forged email addresses on the talk list ... (2002) WCS Newbie question (1997) [WebDNA] Ubuntu 18.04 & Apache2 & WebDNA fcgi - File upload error (2019) WebCat2 Append problem (B14Macacgi) (1997) docs for WebCatalog2 (1997) Unexpected error (1997) RE: HTTP Header info (1997) WebDNA 4.5.1 Now Available (2003) test (1999) ExclusiveLock (2003)