Re: Balancing randomness
This WebDNA talk-list message is from 2000
It keeps the original formatting.
numero = 27956
interpreted = N
texte = On 2/23/00 10:44 am, Joseph D'Andrea so noted...>I think you can do this much easier as I explained in my response >last week to the randomness (or lack thereof) of sdir=ra. You can >accomplish this with just one additional field and only one >additional line of WebDNA and if you are already replacing the >records taht you are selecting from the database then it only >requires a slight change to your webDNA.>>In whatever records you are trying to select randomly, add another >field. I think I called mine RandomWeight. Let's abbreviate it to >[rw] Set this field to some constant value in every record.>>Then when you want a record from the database, do this:>>[search db=data.db&eqSKUdata=find_all&RWsort=1&max=1]>>This will get you the record with the lowest value in [rw] which the >first time through this code is just some random record, because all >the records have the same value in rw.>>Then, later in your code, when you're done with this record, include >the following:>>[replace db=data.db&eqSKUdata=[SKU]]RW=[math][rw]+1[/math][/replace]>>This bumps the value of [RW] by one in this record only. Then the >next time you go through the search, you would get some record >_except_ the one you just got. Subsequent passes through the >database keep returning records with the lowest value of [rw] and >incrementing the value of [rw] in each selected record so that the >pool of records with the lowest [rw] value keeps decreasing and all >records are selected once and only once before being selected again.>>Does this make sense? Hopefully it does because it works.I like the concept, but I'm not getting the desired results (again, this is WebCat 3.0.5b11 on MacOS 8.6). On my setup, the record that's returned with RWsort=1&max=1 is bizarre at best. With a loop of 1000, I first get 8 sets of 4 2 5 3 1, then 4, 2, 5, 3 and 1 in chunks of 81 each. After that, 9 more sets of 4 2 5 3 1 and the whole thing wraps up with 510 4s -- not the most even of distributions : )I've posted the three methods along with the code used to generate each at http://toastdesign.com/randomRob MarquardtDesigner/Resident WireheadToast Design800 Washington Avenue NorthMinneapolis MN 55401612.330.9863 v612.321.9424 fwww.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:
On 2/23/00 10:44 am, Joseph D'Andrea so noted...>I think you can do this much easier as I explained in my response >last week to the randomness (or lack thereof) of sdir=ra. You can >accomplish this with just one additional field and only one >additional line of WebDNA and if you are already replacing the >records taht you are selecting from the database then it only >requires a slight change to your webDNA.>>In whatever records you are trying to select randomly, add another >field. I think I called mine RandomWeight. Let's abbreviate it to >[rw] Set this field to some constant value in every record.>>Then when you want a record from the database, do this:>>[search db=data.db&eqSKUdata=find_all&RWsort=1&max=1]>>This will get you the record with the lowest value in [rw] which the >first time through this code is just some random record, because all >the records have the same value in rw.>>Then, later in your code, when you're done with this record, include >the following:>>[replace db=data.db&eqSKUdata=[SKU]]RW=[math][rw]+1[/math][/replace]>>This bumps the value of [RW] by one in this record only. Then the >next time you go through the search, you would get some record >_except_ the one you just got. Subsequent passes through the >database keep returning records with the lowest value of [rw] and >incrementing the value of [rw] in each selected record so that the >pool of records with the lowest [rw] value keeps decreasing and all >records are selected once and only once before being selected again.>>Does this make sense? Hopefully it does because it works.I like the concept, but I'm not getting the desired results (again, this is WebCat 3.0.5b11 on MacOS 8.6). On my setup, the record that's returned with RWsort=1&max=1 is bizarre at best. With a loop of 1000, I first get 8 sets of 4 2 5 3 1, then 4, 2, 5, 3 and 1 in chunks of 81 each. After that, 9 more sets of 4 2 5 3 1 and the whole thing wraps up with 510 4s -- not the most even of distributions : )I've posted the three methods along with the code used to generate each at http://toastdesign.com/randomRob MarquardtDesigner/Resident WireheadToast Design800 Washington Avenue NorthMinneapolis MN 55401612.330.9863 v612.321.9424 fwww.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:
The IBC root beer has arrived! (1997)
Secure server question (1997)
Updating a database once per day - An example (1998)
WebCat2b13MacPlugIn - [include] doesn't allow creator (1997)
Alternating colors (1997)
[WebDNA] WebDNA restart script (2015)
Date search - yes or no (1997)
Access to shopping cart files (2005)
Extended [ConvertChars] (1997)
BR (1997)
ShowNext example for GeneralStore (1997)
Part 2 - [showif] if variable exists (1998)
RE: Purchased cart being overwritten (1997)
[ListFiles] context & alias (1997)
Help with dates (2001)
Not really WebCat - need HTML Grider (1997)
Help name our technology! (1997)
Authenticate (1999)
What ports does Webcatalog use (2003)
WebCatalog can't find database (1997)