Author |
Topic  |
|
D3mon
Senior Member
   
United Kingdom
1685 Posts |
Posted - 21 February 2003 : 19:49:02
|
I'm developing some banner rotation code but can't work out how to implement a banner 'weighting' system. At the moment, a banner is selected at random, but I'd like to be able to give each banner a particular 'weight' which will affect its likelyhood of being chosen...
Can anyone guide me carefully through the mathematical principle behind this process? |
 Snitz 'Speedball' : Site Integration Mod : Friendly Registration Mod "In war, the victorious strategist only seeks battle after the victory has been won" |
|
Bookie
Average Member
  
USA
856 Posts |
Posted - 21 February 2003 : 22:28:40
|
What if you generate a random number between (and including) 1 and 10. Let's say you have three ads and you want one add to show 60% of the time, another to show 30%, and the last 10%. Generate the random number and then use a series of if/then statements. The following won't be actual code, just explanatory...
if random_number = 1 through 6 then ... show ad 1 elseif random_number = 7 through 9 then ... show ad 2 elseif random_number = 10 then ... show ad 3. end if
Just a thought. I don't know how many ads you are dealing with or how hard this would be to code. It just seems like a reasonable solution to give weight to certain ads. I hope this helps! |
Participate in my nonsense |
 |
|
DavidRhodes
Senior Member
   
United Kingdom
1222 Posts |
Posted - 22 February 2003 : 06:34:05
|
if you use the ASP AdRotator (MSWC.AdRotator), weighting is a built in feature |
The UK MkIVs Forum |
 |
|
VodkaFish
Average Member
  
USA
654 Posts |
Posted - 22 February 2003 : 19:23:53
|
Another way to do it is through counting how many times you've shown the ad and using a math/if system. Do a comparison between the sums and if something is above a certain amount, move on to the next, the next one is above whatever amount, move on as well... until one hits. Sounds more complicated then it is. |
v ø d k â f ï § h |
 |
|
|
Topic  |
|