Re[2]: Balancing randomness
This WebDNA talk-list message is from 2000
It keeps the original formatting.
numero = 27953
interpreted = N
texte = Your method is simpler, but it is not random, merely thorough. This isperfectly reasonable and may be acceptable to your clients. It is not trulyrandom because the sequence will (probably) repeat once the first pass has beencompleted.Here's why: your initial search will not return a random record, it will returnthe first record as judged by WebCat's internal fitness equation. For simplitysake, let's assume that WebCat returns the first record from the naturaldatabase order, i.e. Rec 1. The second search will return Rec 2, because Rec 1will sort last. The third search will return Rec 3 and so on. Once all recordshave been selected once, the first record will again be picked first, followedby each record in turn, because their fitness is unchanged.Unless WebCat does not chose records in the same natural order each time youdo the query (easy enough to check, do the search repeatedly without performingthe update), the sequence will be the same each time, or at least substantiallysimilar. There is nothing random about this sequence.As I said above, this might be fine for your clients, since every ad will getequal face time. But it is not random...John Peacock____________________Reply Separator____________________Subject: Re: Balancing randomness Author:
(WebCatalog Talk)Date: 2/23/00 11:44 AMI 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.___Joe____________________________________________________Joseph D'Andrea JoeDan@West21.comWEST21.com Internet services for the 21st Century http://www.west21.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:
Your method is simpler, but it is not random, merely thorough. This isperfectly reasonable and may be acceptable to your clients. It is not trulyrandom because the sequence will (probably) repeat once the first pass has beencompleted.Here's why: your initial search will not return a random record, it will returnthe first record as judged by WebCat's internal fitness equation. For simplitysake, let's assume that WebCat returns the first record from the naturaldatabase order, i.e. Rec 1. The second search will return Rec 2, because Rec 1will sort last. The third search will return Rec 3 and so on. Once all recordshave been selected once, the first record will again be picked first, followedby each record in turn, because their fitness is unchanged.Unless WebCat does not chose records in the same natural order each time youdo the query (easy enough to check, do the search repeatedly without performingthe update), the sequence will be the same each time, or at least substantiallysimilar. There is nothing random about this sequence.As I said above, this might be fine for your clients, since every ad will getequal face time. But it is not random...John Peacock____________________Reply Separator____________________Subject: Re: Balancing randomness Author: (WebCatalog Talk)Date: 2/23/00 11:44 AMI 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.___Joe____________________________________________________Joseph D'Andrea JoeDan@West21.comWEST21.com Internet services for the 21st Century http://www.west21.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
jpeacock@univpress.com
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:
Secured Order Forms (1998)
Spawn doesn't work as advertised ... (2000)
[OT] Quick Java Question (2007)
Banners (1997)
Bug or syntax error on my part? (1997)
[WebDNA] Crashing (2008)
lookup and two records? (1997)
WebSite and *NO* Authentication Dialog Box!!? (1998)
garbage on page (2000)
Mail Server Needed. (1998)
Saving Text Areas with Orders (1997)
Calendar (1997)
Mac Sever Web Hosting (1999)
[Sum] function? (1997)
problems with 2 tags (1997)
WCS Newbie question (1997)
Newbie problem blah blah blah (1997)
NY taxRates.db? (1997)
Resending - Please help (1999)
Date search bug (1997)