That's like, totally random

Nov 5, 2010

I've received a few inquiries in the last couple of days regarding the use of "random" in some Site Builder assets (notably, the Spotlight Stories). The option allows the page to display a random story each time that page is called.

The question I get is 'why, then, does the same story often show up,' and how 'can you (Dave) fix it.'

Capture

Let's take a look at how the function actually works before I make any comments on why we do it the way we do.

WARNING - TINY BIT OF MATH AHEAD

Basically, a random function will pull a number from between 1 and whatever limit you assign. Therefore, if you requested a number from 1 to 10, you have 10 possible choices. The function has no memory of a previous selection, so it pulls a new number each time, and sometimes that number is the same. When you have a higher limit, the odds go way up that the item will be different. For example, if we're pulling a number from 1 to 100, we've greatly increased the chances that we'll get a different number each time.

In our Spotlight Stories, the limit number is the total number of stories you have in your group(s). So if you have 15 total stories, we'll be pulling a random number from 1 to 15. The more stories you have, the more likely it will be that a new story will be displayed when the page is reloaded.

Now, we *could* track each and every user as they arrive at the page, grab the story number into temporary memory and exclude it from the list when the page is reloaded. This would require additional time for page load, as we would need to add conditions to our simple random function. It would be something like this:

  1. Pull random number
  2. Check to see if random number was just used
  3. If number was just used...
  4. Pull new random number
  5. Rinse, repeat

This isn't very efficient, which is one of the reasons we don't do it. Also, most people *don't* use a site that way. Very few folks are likely to reload a page just to see if there's something else. They are much more likely going to click a link to "view all stories" rather than searching for possible random content. Factored in with the additional time it would take to pick a random number that isn't really random, and we have a solid argument for leaving it as is.


By Dave Krause
Author - Interim Chief Information Officer