Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Random function and number weighting

0 views
Skip to first unread message

Robert K. Foster

unread,
Jun 5, 2000, 3:00:00 AM6/5/00
to
Hello,

I have a random banner ad function, shown below, using a pretty standard
way of picking a random array index value. I am wondering if anyone has
a good way to pick a random number but also "weight" it to one end of
the array or the other. In other words, the function shows a fairly
predictable favoritism toward, say, array elements 0-5 in a 10 element
array. That way element 0 in the array would have a higher percentage of
use then element 9. I also want to do this entirely on the client side,
using only javaScript, and preferably without a cookie.

Thanks for any ideas.
Bob.

// Functions
function pickad_banner()
{
var s ;
var n ;
n=Math.round( Math.random() * (ad_ban_array.length-1) ) ;
s=ad_ban_array[n] ;
return s ;
}

0 new messages