Here’s an interesting mathematics and computer science question: how random is Microsoft’s new EU browser choice screen? It’s not, according to several statistical analysis articles published during the past week.

IBM engineer Rob Weir has produced one of the better reports about the browser ordering on browserchoice.eu. The non-randomness is quite complex and it didn’t necessarily favor Internet Explorer; IE appeared last half the time and Chrome was more likely to appear in the first 3 positions.

Bringing Chaos from Order

Generating random numbers on a digital device is not easy. Most implementations use a mathematical function which returns a pseudo-random number. It may appear random, but the sequence is predictable. However, this is not the issue Microsoft encountered.

There are various algorithms to ‘randomly’ shuffle an array of items but, according to Rob Weir, Microsoft chose the worst one. They used the following JavaScript comparison function for array.sort():

``````
function RandomSort(a,b)
{
return (0.5 - Math.random());
}
``````

Since the comparison function returns a random result, the sorting process would receive inconsistent information regarding its progress. It could perform no swaps or, in theory, it could continue indefinitely. Ultimately, the results are not uniformly random.

Weir suggests Microsoft should have used the Fisher-Yates shuffle. In essence, this randomly picks an item from the source array and moves it to the end of a destination array. The process continues until all items from the original array have been moved.

Does it Matter?

In my opinion — no. Most individuals will see the screen once or twice. Shuffling inconsistencies do not become apparent until you examine population samples containing thousands of users.

But do Microsoft need further legal wrangles? For all you lawyers excitedly anticipating a long-winded technical case about browser bias — you’re too late. Microsoft has changed their array shuffling algorithm:

``````
function ArrayShuffle(a) {
var d, c, b=a.length;

while(b) {
c=Math.floor(Math.random()*b);
d=a[--b];
a[b]=a
;
a

``````=d;
}
}
```
Given a five-element array, the function will loop through elements 4 to 0 (variable b). A random number is generated between 0 and b (variable c). Elements b and c are then swapped. It’s not the Fisher-Yates algorithm, but it’s much better and will certainly end after 5 iterations (although it could end after 4 since the last element will always be swapped with itself).
I suspect it will result in a more uniform random distribution of browser positions. Eager statisticians will certainly be scrutinizing the results!
```
Tags: browser, chrome, firefox, microsoft, opera, safari

• ivanfx

Seriously, who cares? This only affects us EU folks and nobody else. Plus anyone who has a choice ditches IE (people in large companies often don’t have the choice).
Heck, even my mom uses Chrome (because it says Google Chrome on the icon) instead of IE.

Bottom line – get over it.

• Thirteenva

Really, a blog post on this? This is ridiculous. The choice screen is silly to begin with and analyzing the randomness of a page that a user likely sees only once is also a waste.

If someone really wants to waste thought on this screen they could at least analyze how/why users are choosing certain browsers when faced with this choice. Are people choosing IE because it’s known? Google because their “trusted”, etc…

• http://www.optimalworks.net/ Craig Buckler

@Thirteenva
As mentioned, this is really an exercise in computer science and statistical analysis. It shows how a seemingly innocent piece of code had unexpected consequences. Call me a geek, but I found it interesting!

• http://www.tyssendesign.com.au Tyssen

Really, a blog post on this? This is ridiculous.

The post isn’t ridiculous, Craig is just reporting on developments in the web dev world. The ridiculous part is that other people have spent so much time analysing this stuff to the point of writing reports about it.

• http://www.optimalworks.net/ Craig Buckler

@Ivanfx

even my mom uses Chrome

Did she install it herself or did you do it for her? Most of us have recommended or installed alternative browsers to friends and family, but not everyone has that support. Therefore, there’s absolutely nothing wrong with the browser choice screen. It will educate users at the very least.

Although the browser shuffling case is fairly irrelevant, I still think it’s useful for developers to understand what’s happening. Many are developing critical applications where statistical bias could have more serious consequences.

• Carlo

Maybe you people don’t get the point of this statistic issue. If a browser is more then others at the first place in the ballot, it will be chosen more times (not by the single user, but the whole users community).

Example: if, on 100 Windows installation, Chrome is 50% of the times at the first position, it means that 50% of the users will see that browser at the first place, and that is quite distant from a perfectly random 20% (100/5). Get it?

• Clintonio

It’s funny, this is like, first year CompSci material… Microsoft is how huge?

• http://logicearth.wordpress.com logic_earth

@Carlo, have any actual supporting data?

• http://www.optimalworks.net/ Craig Buckler

@carlo
You’re assuming that more people will choose the browser at position #1. I’m no psychoanalyst, but I doubt that’s the case. I suspect many will choose something they’re familiar with or a name/logo they like.

You could make a case that the browser in position #5 will be picked more often because it’s the last one most people will view.

Even if you disregard viewing sequences and personal preferences, people rarely choose at random. Ask someone to pick a number between 1 and 5 — they’re more likely to pick 2, 3, or 4 than 1 or 5 because the middle numbers feel more random.

• Jay Peterson

I agree with Craig. People will pick what they are most comfortable with no matter how random they try and make things. Everybody has their favorite browser and that’s the one they are going to chose no matter if it comes up 1st, 5th, or somewhere in between!

• Daniel

Check it: http://www.realbrowserchoice.eu

This is very random :P Firefox/Chrome rockssss!!!

I wonder why they didn’t use the Fisher-Yates shuffle…. Surely anyone who has given serious thought to shuffling algorithms would have run across Fisher-Yates and it’s pretty simple to apply. Mind you, it isn’t perfect but it would certainly keep the critics and couch statisticians at bay.

• Carlo

The first position and the last one on a given list are statistically more choosen by undecided people. It’s a well know fact, I’m surprised you don’t know. And the first one is better than the last.
For example that’s why politic parties always tried to have the first or the last place on the voting paper (in electoral systems where this is not decided previously, ex. alphabetically).

• W2ttsy

I think the point of craigs post was to demonstrate the issues with using this sort of code for creating random results. It doesn’t necessarily have to be Microsofts browser choice screen, but it could be a product picker, advertising messages, random quote of the day, anything. These sort of things do have massive issues with a poor algorithms as there is a higher chance of more refreshes/impressions than a single use only application like an application choice menu…

• http://www.optimalworks.net/ Craig Buckler

@Carlo

Itâ€™s a well know fact

This is the first time a browser choice screen has been offered. There are no ‘facts’ and you cannot make assumptions about a user’s technical knowledge. I do not believe many people will make a totally uninformed choice — many could close the window or hit “choose later” if they don’t know what they’re doing.

Voting papers are a little different. They normally have a list in vertical orientation and can offer considerably more than 5 choices. How many undecided voters would bother to turn up? Even then, I suspect many would choose a name/political party they recognise rather than a total unknown or a purely random choice.

The only fact is that we’ll never know. MS have fixed the random distribution and they don’t appear to be recording browser positions against chosen options.

Recommended for you

Special Offer
Free course!

Git into it! Bonus course Introduction to Git is yours when you take up a free 14 day SitePoint Premium trial.