Re: Balancing randomness

This WebDNA talk-list message is from

2000


It keeps the original formatting.
numero = 27979
interpreted = N
texte = On 2/23/00 4:26 pm, Christer Olsson so noted...>I belive your first results are based on a bad formula: > >[math]pick=[format .0f][math]pick=(([random]/100)*4)+1[/math][/format][/math] > >The part [random]/100)*4)+1 does not do what I think you expect it to do. > >If [random] is from 1-12 (12 figures) your formula will result in 1 >If [random] is from 13-37 (25 figures) your formula will result in 2 >If [random] is from 38-61 (24 figures) your formula will result in 3 >If [random] is from 62-87 (26 figures) your formula will result in 4 >If [random] is from 88-100 (13 figures) your formula will result in 5Excellent call. I had been using [format .0f] as an integer function, which is wrong since [format] is rounding up, not just lopping off the decimal (resulting in the quantities of the end numbers being skewed -- 1 would hit 13 times, 5 would hit 12, the rest at 25).By changing the formula to use floor( )...[math]pick=floor(([random]/100)*5)+1[/math] On my loop of 1000, I get a *far* better distribution:1 = 190 (19%) 2 = 202 (20.2%) 3 = 199 (19.9%) 4 = 207 (20.7%) 5 = 202 (20.2%)Whoo hoo!Now to look through a few websites and find where else I've used my crappy random routine : )P.S. [random] on Mac WC 3.0.5b11 gives numbers from 0-99 -- should I be concerned?Rob Marquardt Designer/Resident Wirehead Toast Design800 Washington Avenue North Minneapolis MN 55401 612.330.9863 v 612.321.9424 f www.toastdesign.com ------------------------------------------------------------- Brought to you by CommuniGate Pro - The Buzz Word Compliant Messaging Server. To end your Mail problems go to .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 Associated Messages, from the most recent to the oldest:

    
  1. Re: Balancing randomness (Rob Marquardt 2000)
  2. Re: Balancing randomness (Peter Ostry 2000)
  3. Re: SOLUTION.... Re: Balancing randomness (Rob Marquardt 2000)
  4. Re: Balancing randomness (Christer Olsson 2000)
  5. Re: SOLUTION.... Re: Balancing randomness (Kenneth Grome 2000)
  6. Re: SOLUTION.... Re: Balancing randomness (Rob Marquardt 2000)
  7. SOLUTION.... Re: Balancing randomness (Joseph D'Andrea 2000)
  8. Re[2]: Balancing randomness (Kenneth Grome 2000)
  9. Re: Balancing randomness (Joseph D'Andrea 2000)
  10. Re: Balancing randomness (John Butler 2000)
  11. Re[2]: Balancing randomness (Joseph D'Andrea 2000)
  12. Re: Balancing randomness (Miguel Castaneda 2000)
  13. Re: Balancing randomness (Rob Marquardt 2000)
  14. Re: Balancing randomness (Joseph D'Andrea 2000)
  15. Re[2]: Balancing randomness (jpeacock@univpress.com 2000)
  16. Re[2]: Balancing randomness (jpeacock@univpress.com 2000)
  17. Re: Balancing randomness (Peter Ostry 2000)
  18. Re: Balancing randomness (Rob Marquardt 2000)
  19. Re: Balancing randomness (Joseph D'Andrea 2000)
  20. Re: Balancing randomness (jpeacock@univpress.com 2000)
  21. Balancing randomness (Rob Marquardt 2000)
On 2/23/00 4:26 pm, Christer Olsson so noted...>I belive your first results are based on a bad formula: > >[math]pick=[format .0f][math]pick=(([random]/100)*4)+1[/math][/format][/math] > >The part [random]/100)*4)+1 does not do what I think you expect it to do. > >If [random] is from 1-12 (12 figures) your formula will result in 1 >If [random] is from 13-37 (25 figures) your formula will result in 2 >If [random] is from 38-61 (24 figures) your formula will result in 3 >If [random] is from 62-87 (26 figures) your formula will result in 4 >If [random] is from 88-100 (13 figures) your formula will result in 5Excellent call. I had been using [format .0f] as an integer function, which is wrong since [format] is rounding up, not just lopping off the decimal (resulting in the quantities of the end numbers being skewed -- 1 would hit 13 times, 5 would hit 12, the rest at 25).By changing the formula to use floor( )...[math]pick=floor(([random]/100)*5)+1[/math] On my loop of 1000, I get a *far* better distribution:1 = 190 (19%) 2 = 202 (20.2%) 3 = 199 (19.9%) 4 = 207 (20.7%) 5 = 202 (20.2%)Whoo hoo!Now to look through a few websites and find where else I've used my crappy random routine : )P.S. [random] on Mac WC 3.0.5b11 gives numbers from 0-99 -- should I be concerned?Rob Marquardt Designer/Resident Wirehead Toast Design800 Washington Avenue North Minneapolis MN 55401 612.330.9863 v 612.321.9424 f www.toastdesign.com ------------------------------------------------------------- Brought to you by CommuniGate Pro - The Buzz Word Compliant Messaging Server. To end your Mail problems go to .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 Rob Marquardt

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:

MasterCounter Weirdness -Resolved! (1997) insecuretextvars preference doesn't work (2000) Search in 2 or more catalogs (1997) What file? (1997) OT - webserver backups (2003) OT - webdnadev.net ...... links bad??? (2005) Grep Question - NOT YET SOLVED (fwd) (2003) Quickly reordering search results (2001) getting images' width/height (1998) WebCat hosting providers? (1997) Multiple Newcarts (1996) RE: Discounting prices across a site (1997) emailer (1997) Custom Shipping Charges (1997) [WebDNA] Will Q2/2010 be the best quarter for WebDNA? (2010) Problems with large number of items in a cart. (1998) Target wit redirect (1998) Using [Showif] tag. Mac (1997) can WC render sites out? (1997) Strange Question (2003)