Re: random prob

This WebDNA talk-list message is from

2003


It keeps the original formatting.
numero = 50398
interpreted = N
texte = Ron Ceballos wrote: > i'm having a bit of trouble with this code -- for the life of me i can't get > it to truly give me unique, random numbers, it always duplicates 2 values > First things first, the following sequence of numbers is perfectly legitimate in a random sequence: ...1,2,3,4,5,5,5,5,6,7,8....Truly random includes the possibility of both finite localized patterns, as well as duplicates. You need to decide what you are really looking for; it sounds like what you want is non-repeating random numbers in a certain range.Secondly, performing [math] in general and especially [math ceil()] on random numbers will cause the resulting numbers to become non-random (i.e. the numbers 8 through 14 will all map to 2 when divided by 7 and then [math ceil()]'d). If you have to do it this way, use [math floor([random format=float]*[x])] [!]where x is the max number you want to get[\!]since that will be a better distribution of numbers.A better technique is to take [random] in a [loop] and throw out any number out of the range you are interested in (as long as your range is < 100), or in your case any repeated digit.Lastly, I really question the programming technique of storing numerical values in text variables. Show of hands, how many people have actually written templates where you ran out of math variables (that's 150 individually named variables)?John-- John Peacock Director of Information Research and Technology Rowman & Littlefield Publishing Group 4501 Forbes Boulevard Suite H Lanham, MD 20706 301-459-3366 x.5010 fax 301-429-5748 ------------------------------------------------------------- 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://webdna.smithmicro.com/ Associated Messages, from the most recent to the oldest:

    
  1. Re: random prob (Ron Ceballos 2003)
  2. Re: random prob (Glenn Busbin 2003)
  3. Re: random prob (Rob Marquardt 2003)
  4. Re: random prob (Ron Ceballos 2003)
  5. Re: random prob (Glenn Busbin 2003)
  6. Re: random prob (Beljaeff, Gene 2003)
  7. Re: random prob (Rob Marquardt 2003)
  8. Re: random prob (Ron Ceballos 2003)
  9. Re: random prob (Rob Marquardt 2003)
  10. Re: random prob (Ron Ceballos 2003)
  11. Re: random prob (Rob Marquardt 2003)
  12. Re: random prob (John Peacock 2003)
  13. Re: random prob (Glenn Busbin 2003)
  14. Re: random prob (Ron Ceballos 2003)
  15. Re: random prob (Rob Marquardt 2003)
  16. random prob (Ron Ceballos 2003)
Ron Ceballos wrote: > i'm having a bit of trouble with this code -- for the life of me i can't get > it to truly give me unique, random numbers, it always duplicates 2 values > First things first, the following sequence of numbers is perfectly legitimate in a random sequence: ...1,2,3,4,5,5,5,5,6,7,8....Truly random includes the possibility of both finite localized patterns, as well as duplicates. You need to decide what you are really looking for; it sounds like what you want is non-repeating random numbers in a certain range.Secondly, performing [math] in general and especially [math ceil()] on random numbers will cause the resulting numbers to become non-random (i.e. the numbers 8 through 14 will all map to 2 when divided by 7 and then [math ceil()]'d). If you have to do it this way, use [math floor([random format=float]*[x])] [!]where x is the max number you want to get[\!]since that will be a better distribution of numbers.A better technique is to take [random] in a [loop] and throw out any number out of the range you are interested in (as long as your range is < 100), or in your case any repeated digit.Lastly, I really question the programming technique of storing numerical values in text variables. Show of hands, how many people have actually written templates where you ran out of math variables (that's 150 individually named variables)?John-- John Peacock Director of Information Research and Technology Rowman & Littlefield Publishing Group 4501 Forbes Boulevard Suite H Lanham, MD 20706 301-459-3366 x.5010 fax 301-429-5748 ------------------------------------------------------------- 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://webdna.smithmicro.com/ John Peacock

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:

Bug with convertchars crashes WebCat!! (1999) off topic - dna snipets (1997) creating files dynamically (2002) Adding Shipping Costs based on percent of subtotal (1997) Re:Emailer tracking (1997) Determining Method (2000) Showing unopened cart (1997) Multiple prices (1997) Date search - yes or no (1997) Data Entry ... Excel Style ... How To? (2001) RE: type 2 errors with ssl server (1997) Separate SSL Server (1997) Mail Server Needed. (1998) [WebDNA] 6.2.1 fails on Apache 2.4.6 (2014) carriage returns in data (1997) Resume Catalog ? (1997) Updating a database once per day - An example (1998) [/application] error? (1997) Hard Questions ? (1997) Webcatalog Future?!? (2000)