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 is perfectly reasonable and may be acceptable to your clients. It is not truly random because the sequence will (probably) repeat once the first pass has been completed.Here's why: your initial search will not return a random record, it will return the first record as judged by WebCat's internal fitness equation. For simplity sake, let's assume that WebCat returns the first record from the natural database order, i.e. Rec 1. The second search will return Rec 2, because Rec 1 will sort last. The third search will return Rec 3 and so on. Once all records have been selected once, the first record will again be picked first, followed by each record in turn, because their fitness is unchanged.Unless WebCat does not chose records in the same natural order each time you do the query (easy enough to check, do the search repeatedly without performing the update), the sequence will be the same each time, or at least substantially similar. There is nothing random about this sequence.As I said above, this might be fine for your clients, since every ad will get equal 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.com WEST21.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:

    
  1. Re[2]: Balancing randomness (jpeacock@univpress.com 2000)
  2. Re[2]: Balancing randomness (jpeacock@univpress.com 2000)
Your method is simpler, but it is not random, merely thorough. This is perfectly reasonable and may be acceptable to your clients. It is not truly random because the sequence will (probably) repeat once the first pass has been completed.Here's why: your initial search will not return a random record, it will return the first record as judged by WebCat's internal fitness equation. For simplity sake, let's assume that WebCat returns the first record from the natural database order, i.e. Rec 1. The second search will return Rec 2, because Rec 1 will sort last. The third search will return Rec 3 and so on. Once all records have been selected once, the first record will again be picked first, followed by each record in turn, because their fitness is unchanged.Unless WebCat does not chose records in the same natural order each time you do the query (easy enough to check, do the search repeatedly without performing the update), the sequence will be the same each time, or at least substantially similar. There is nothing random about this sequence.As I said above, this might be fine for your clients, since every ad will get equal 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.com WEST21.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:

WebCat2b13MacPlugIn - [showif][search][/showif] (1997) Bug alert! (1997) The beginning (1997) UPDATE PROBLEM (1997) plugin-acgi, different results (1997) WebCat B13 Mac CGI -- Frames question (1997) RequiredFields template (1997) Triggers Suck! (2000) Adding up weights (1998) Formulas.db (2000) WebCatalog f2 Installation (1997) Showing unopened cart (1997) WebCat2b12 CGI Mac -- Problems propagating the cart through frames...still (1997) [searchString] (1997) webdelivery.html and webna (1997) rotating thumbnails (1997) Unexpected error (1997) links to .db's ? (1999) IE-caching (1998) Questions (1998)