The random image thing on the right of this page is supposedly, er, random – so how can one account for things like the above happening? Here, I blogged about my mum’s painting, and hey presto! It randomly appears on the right too! It’s not as if it’s unusual either, I’ve seen matches like that in the past, but the odds should be 14,762 to 1 (the number of images I have on Flickr).
Also, I know of friends who have reported random pictures of themselves showing up when they’ve checked the mumble, the chances of which are almost as slim as the above!
Is there magical jiggery pokery going on around here?
It’s actually pretty tricky to pick “random” items out of a database; especially when you’ve got a large number of items and need to scale to a lot of users. It’s very easy to make selections which are biased by deleted items, permissions, etc.
You can get some idea of why it’s tricky when you consider how you’d do it yourself; you’ve got a big batch of photos, but you don’t want to look through all of them, but you also don’t want to pick certain ones because they’re private, or not very good, or whatever. If you just open a page at random (using dice, say; people are notoriously bad at making random choices themselves), and plonk your finger down, you might find you don’t actually want that one.. so you move to the next one, and the next, and the next, and finally select your “random” photo.
What just happened? If you happened to make your first selection any one of those unsuitable items, *all* those selections will end up mapping to the one later photo, which will subsequently appear a lot more often than average.
You might also get deliberate bias; pick something more recent, or popular, or from a smaller pregenerated list that gets recycled. It doesn’t take much for some photos to be picked “randomly” one every few hundred times instead of every 15 thousand.
yeah, I see your point, and I’m inclined to believe that Flickr’s Random photo thing is biased towards recent photos, although it doesn’t say anything about that in the literature I’ve read.
The other random thing I don’t understand is how my random header at the top of the mumble (‘random’ out of a choice of 22 or so headers I created) sometimes comes up blank – there is no blank option!
The other random thing I don’t understand is how my random header at the top of the mumble (‘random’ out of a choice of 22 or so headers I created) sometimes comes up blank – there is no blank option!
That’ll be cos of your typo: banner[29]=”http://www.tamegoeswild.com/images/headers/dm_header-20.jpg”. Try banner[19] = .. 🙂
You might also consider dropping the array and just doing something like:
var random = Math.round(1 + (21 * Math.random()));
if (random < 10) random = "0" + rand;
document.write(‘ background:url(“http://www.tamegoeswild.com/images/headers/dm_header-‘ + random + ‘.jpg”) … ‘);
ah crikey I must have spent at least an hour when I first added that trying to figure out where I messed up, how I missed that typo I don’t know!
Thanks soooo much. Really appreciate that!
The code behind this site would probably make any developer cry. A product of years of amateur trial and error.
Thomas,
I’ll keep the shortened version on file, I tried to implement it but got something wrong , so will have another look when I have more time. Thanks for that though, appreciate it.