Slashdot Mirror


Schooling Microsoft On Random Browser Selection

Rob Weir got wind that a Slovakian tech site had been discussing the non-randomness of Microsoft's intended-to-be-random browser choice screen, which went into effect on European Windows 7 systems last week. He did some testing and found that indeed the order in which the five browser choices appear on the selection screen is far from random — though probably not intentionally slanted. He then proceeds to give Microsoft a lesson in random-shuffle algorithms. "This computational problem has been known since the earliest days of computing. There are 5 well-known approaches: 3 good solutions, 1 acceptable solution that is slower than necessary and 1 bad approach that doesn’t really work. Microsoft appears to have picked the bad approach. But I do not believe there is some nefarious intent to this bug. It is more in the nature of a 'naive algorithm,' like the bubble sort, that inexperienced programmers inevitably will fall upon when solving a given problem. I bet if we gave this same problem to 100 freshmen computer science majors, at least 1 of them would make the same mistake. But with education and experience, one learns about these things. And one of the things one learns early on is to reach for Knuth. ... The lesson here is that getting randomness on a computer cannot be left to chance. You cannot just throw Math.random() at a problem and stir the pot and expect good results."

436 comments

  1. LAST by DamonHD · · Score: 5, Funny

    Hmm, there's a nice shuffle implementation in Java that Microsoft could use... Oh, wait...

    Rgds

    Damon

    --
    http://m.earth.org.uk/
    1. Re:LAST by Anonymous Coward · · Score: 0

      There are no random algorithms.

      Nothing to see here but M$ bashing, move along.

    2. Re:LAST by jez9999 · · Score: 1

      Hmm, there's a nice shuffle implementation in Java that Microsoft could use... Oh, wait...

      They could, however, just copy/paste it into a C# sourcecode file and compile. ;-)

    3. Re:LAST by DamonHD · · Score: 1

      But that would be THEFT!!!11!1!!!

      --
      http://m.earth.org.uk/
  2. Adding randomness... by Idbar · · Score: 3, Funny

    just requires something like:
    pickabrowser() {
    if (rand()>0.05) {
    use IE
    } else {
    pickabrowser()
    }
    }

    Nobody said anything about bias.

    1. Re:Adding randomness... by DamonHD · · Score: 1

      I think that the EU *might* take a view about that algorithm... %-P

      Rgds

      Damon

      --
      http://m.earth.org.uk/
    2. Re:Adding randomness... by K.+S.+Kyosuke · · Score: 4, Funny

      Exactly, as there is always a chance for you to get a better browser due to a stray alpha particle.

      --
      Ezekiel 23:20
  3. damned faintly praising? by Anonymous Coward · · Score: 0, Offtopic

    if we gave this same problem to 100 freshmen computer science majors, at least 1 of them would make the same mistake (as Microsoft)

    Ouch, that's gotta sting.

    1. Re:damned faintly praising? by Anonymous Coward · · Score: 0

      not really. multinational corporations don't feel shame.

      this is one of the highest-profile pieces of code microsoft had to come up with, and they fucked it up. we're supposed to believe it was unintentional?

    2. Re:damned faintly praising? by sopssa · · Score: 4, Informative

      Is picking a worse random number generation function (the default one in C and JS) really fucking up?

      And btw, it looks like their choice promotes all other browsers than IE almost 2x more!

      Position I.E. Firefox Opera Chrome Safari
      1 1304 2099 2132 2595 1870
      2 1325 2161 2036 2565 1913
      3 1105 2244 1374 3679 1598
      4 1232 2248 1916 590 4014
      5 5034 1248 2542 571 605

      I can already see all the comments how MS would be favoring IE with this (summary conveniently left that one out), but as it is they're promoting the other browsers almost double more.

    3. Re:damned faintly praising? by Anonymous Coward · · Score: 0

      It won't sting because very few programmers implement effective random selections. Check out your mp3 player on shuffle (iPods are abyssal) or even a random feature when playing CDs in your car. This is something that programmers assume just works, but never actually test.

    4. Re:damned faintly praising? by GIL_Dude · · Score: 3, Informative

      Right; the point of "random" was just that Microsoft didn't PICK the order that the browsers would show up in. For the business purpose required, the solutions selected was adequate and met the requirement. This guy is talking about trying to get highly random stuff like you might need in encryption or quantum physics simulations. While interesting, those higher randomness generators aren't required by the need here.

    5. Re:damned faintly praising? by EvanED · · Score: 4, Insightful

      Is picking a worse random number generation function (the default one in C and JS) really fucking up?

      There's no problem with the function they're using; the problem is how they're using it. If 'rand()' were perfect, their technique would still suck.

      I can already see all the comments how MS would be favoring IE with this (summary conveniently left that one out), but as it is they're promoting the other browsers almost double more.

      I do think the summary should have mentioned that bias, but I don't think it's quite as good a position as you convey. I bet the far right position is better than #3 and #4 at least.

      (If I wanted to put on my conspiracy hat -- which I don't, I don't really believe this -- I'd say that MS wanted to bias it towards them and decided that biasing it toward #1 would be too blatant, but that #5 was "good enough".)

    6. Re:damned faintly praising? by pelrun · · Score: 1

      Hah! The mp3 shuffle thing isn't a case of poor randomisation - humans just tend to pick a poor definition of random here. Usually people expect "play stuff I haven't heard recently, and in a completely new order that I haven't heard before". True random shuffle will give you songs and orders you've already heard, and your brain is good at picking them up.

    7. Re:damned faintly praising? by beelsebob · · Score: 5, Insightful

      No, the point was that no one browser got unfairly pushed to the top all the time. This algorithm does push a certain browser higher more often than not, and hence is not fit for it's job.

    8. Re:damned faintly praising? by donaggie03 · · Score: 1

      True random shuffle will give you songs and orders you've already heard --- just as likely as any other song and order combination. With a decently large selection of music, the chance to randomly pick the exact same song and order combination as one you have recently heard is quite low. In other words, your randomization technique sucks.

      --
      Three days from now?? Thats tomorrow!! ~Peter Griffin
    9. Re:damned faintly praising? by 644bd346996 · · Score: 5, Insightful

      Even with a very high quality entropy source, the algorithm Microsoft used will result in a very non-uniform distribution.

      Clearly, Microsoft didn't care about this enough to assign one of their experienced coders to it, which is odd given the legal involvement. Either the technical side of MS ignored the legal department's explanation of the importance of the browser ballot to MS's ability to do business on a particularly profitable continent, or someone powerful in MS decided to spite the EU by assigning low quality programmers to the project.

    10. Re:damned faintly praising? by DamonHD · · Score: 2, Informative

      Yes, indeed, you've hit the nail on the head.

      A very sloppy shallow unworkmanlike solution to a very high profile legal issue.

      Almost as clever as the 'messing up pages shown to Opera' issue, though I suspect that that was deliberate and this not.

      Rgds

      Damon

      --
      http://m.earth.org.uk/
    11. Re:damned faintly praising? by cgenman · · Score: 3, Insightful

      If someone on my team returned that piece of code and insisted that it met the requirements, I would find another team member. A random shuffle is supposed to give ballpark equal positions. This algorithm gave Internet Explorer the rightmost position in the list a full %50 of the time. It's not like he's complaining that the algorithm be up to encryption grade randomness, but rather that it fails even the human eyeball test. %10 statistical variation? Sure, whatever. But getting a particular slot a full %250 more than you should, when you're ordered by the court to make something random? That's really poor coding.

      And the sad thing is, with just FIVE things to sort and no real pressure for speed or RAM, there is no reason why it should be this poor. There is essentially unlimited computing power and RAM, and it fails to produce even casually random results. It's just an inexperienced coder and an inexperienced team making freshman mistakes. Considering this was part of an EU directive, I would have expected at least a few higher level eyeballs would have caught this.

    12. Re:damned faintly praising? by SpinyNorman · · Score: 1

      Did you actually read TFA - at least the raw data at the TOP of the article ?!

      Microsoft IE was in 5th place (out of 5) 50%, as opposed to a random 20%, of the time !!

      Hard to say whether that's in their favor or not ... last place is just as special a position as 1st place.

    13. Re:damned faintly praising? by teg · · Score: 2, Insightful

      True random shuffle will give you songs and orders you've already heard --- just as likely as any other song and order combination.

      Yes, but people forget most of the sequence... they just notice the times when it is the same artist in a row. Thus, the part of the elections evaluated when thinking "this isn't random" is extremely biased. Humans are good at seeing patterns.

    14. Re:damned faintly praising? by larry+bagina · · Score: 1

      Is not understanding the article (the problem wasn't with the random number generation but with how the choices were shuffled) really fucking up?

      --
      Do you even lift?

      These aren't the 'roids you're looking for.

    15. Re:damned faintly praising? by Anonymous Coward · · Score: 0

      I believe GP was referring to order pairs, not orders of arbitrary length.

    16. Re:damned faintly praising? by Anonymous Coward · · Score: 0

      It also places IE in the other distinguished spot, the last one, twice as often as any other browser. That may or may not be deliberate or advantageous, but it's certainly not adequately random.

    17. Re:damned faintly praising? by Anonymous Coward · · Score: 1, Informative

      Really? For example, hearing the same artist twice within some period of time is a situation where the birthday paradox applies. Even with a very large number of songs your brain will probably find *some* pattern, and you'll be an idiot and say the shuffle wasn't truly random. People experience a shuffle algorithm that avoids artists that it has recently played to be more random than a truly random shuffle.

    18. Re:damned faintly praising? by maraist · · Score: 1

      Did you read the article? The algorithm chosen could produce an infinite loop.

      --
      -Michael
    19. Re:damned faintly praising? by Anonymous Coward · · Score: 0

      No, you twonk, random functions should not take into account previous selections, durrr! Do it eleven billionty times and then claim bias. Jeez.

    20. Re:damned faintly praising? by cgenman · · Score: 5, Informative

      The relevant code is in their Javascript:

      aBrowserOrderTop5.sort(RandomSort); (they repeat this twice for some reason) ...
      function RandomSort (a,b)
      {
              return (0.5 - Math.random());
      }

      This takes the browser's built-in sorting function, tells it to sort by an essentially random criteria, and hopes that it all works out. Unfortunately, this is highly dependent on the implementation of the built-in sort function, and that's up to the browser designer to create. The only constraint on the structure of sort is that it must successfully order comprehensible data, which does not mean that it will properly randomize data when provided. Essentially, they overloaded a black-box function that wasn't designed for randomization in the hopes that it would work.

      For an instance of why this wouldn't work, consider the case of the last item. Say that you're sorting a list of 5 letters. Now say that you're most of the way through the list, having properly sorted the first 4 letters into "A, B, D, E", with just the 5th letter C left. So you step through.
      Does C come before E? Yes.
      Does C come before D? Yes.
      Does C come before B? No.
      C must go between B and D, and the list will look like "A , B , C , D , E." It will be sorted correctly every time.

      Now let's throw that randomization into the middle there. Let's start again with the list, though since we're randomizing let's call them item 1, 2, 3, and 4. If we're properly randomly sorting the last item 5 into the list, it should have equal chances of showing up everywhere. But remember, we're still using the sorting algorithm from above, we're just flipping a coin at each question instead of actually comparing. So what we get is:

      Does 5 come before 4? 50% yes, or stop
      Does 5 come before 3? 50% yes, or stop
      Does 5 come before 2? 50% yes, or stop

      etc. But because it's iterative, those 50% chances stack. You only get to the second question half of the time, so you only get to the third question half of that half of the time. And essentially what you wind up with is a % chance of the last number being sorted into each of the slots as: 3%, 6%, 12%, 25%, 50%. This is obviously not a random distribution curve.

      This is not necessarily the sort algorithm that Microsoft uses in I.E. (The 50% chance of staying as the last element is a bit suspicious, though, as is running their code twice). But it does point out unequivocably that you can't overload an off-the-shelf sort algorithm with a randomizing comparator and expect the outcome to follow a genuinely random distribution curve. They really ought to have an in-house random sort algorithm that their developers can pull from.

      (Thanks to another poster for finding the first google hit that describes this method.).

    21. Re:damned faintly praising? by RobertM1968 · · Score: 1

      Worst is, I suspect you don't need to be an experienced coder to have solved this in a more random manner. I suspect like with almost any programming tool, somewhere there is a better random number/selection generator available, which the coder simply chose not to use.

    22. Re:damned faintly praising? by RobertM1968 · · Score: 1

      Wow, rather insightful - and true. The same is done often in TV shows and such, with the last credit all by itself...

      And...
      John Doe as Someone

      It's even more important in this particular scenario as the eye is generally drawn to the left or right most entry.

      Of course, being able to say "Gee, we're last more times than anyone else" then becomes an invalid excuse for the lack of randomness.

    23. Re:damned faintly praising? by mabinogi · · Score: 1

      it wasn't a problem with the random number generator - it was a problem with where the number was used.
      They "shuffled" by passing a user defined "compare" function which returned random results to a sort function.
      For sort to work properly, the results must be repeatable - so basically rather than create a random sort, they just created a broken sort, and the result would then be dependant on the actual sorting algorithm used by the language.

      --
      Advanced users are users too!
    24. Re:damned faintly praising? by Chuck+Chunder · · Score: 1

      I can already see all the comments how MS would be favoring IE with this (summary conveniently left that one out), but as it is they're promoting the other browsers almost double more.

      I think you'd need user testing to determine that.

      Do people choose the first one on the list or do they read the whole list and then maybe select the last one more often?

      --
      Boffoonery - downloadable Comedy Benefit for Bletchley Park
    25. Re:damned faintly praising? by Unequivocal · · Score: 1

      Nice write up - thanks. Kind of reminds me of the counter-intuitive monty hall class of problems.

    26. Re:damned faintly praising? by jgrahn · · Score: 2, Informative

      Is picking a worse random number generation function (the default one in C and JS) really fucking up?

      The default rand(3) in C doesn't have to suck -- it doesn't on Linux or the BSDs. I see no evidence that it does in *any* major systems today, though apparently it did back in the 1980s when it got that reputation.

    27. Re:damned faintly praising? by SmitherIsGod · · Score: 1

      It doesn't. How could it, without communicating with a central server for the arraignment of the choices.

      He ran it for 10,000 times and came up with this graph:

      Position I.E. Firefox Opera Chrome Safari
      1 1304 2099 2132 2595 1870
      2 1325 2161 2036 2565 1913
      3 1105 2244 1374 3679 1598
      4 1232 2248 1916 590 4014
      5 5034 1248 2542 571 605

      Looks pretty significant to me. Chrome was in position 5 almost 10 times less than IE was.

    28. Re:damned faintly praising? by Anonymous Coward · · Score: 0

      OMG don't click on that link. After just a cursory glance at that code, I wanted to poke my eyes out!

    29. Re:damned faintly praising? by j00r0m4nc3r · · Score: 1

      so basically rather than create a random sort, they just created a broken sort, and the result would then be dependant on the actual sorting algorithm used by the language.

      And more importantly as the author points out, the specific implementation of the sort algorithm is not guaranteed by any standard, so a broken sort could theoretically end up as an infinite loop.

    30. Re:damned faintly praising? by rgmoore · · Score: 1

      (they repeat this twice for some reason)

      I suspect that the reason is still incompetence rather than ill intent. They tried their shuffling algorithm, but it failed to pass whatever test they used to see if the order was random. They were either too incompetent or in too much of a hurry to look up a better method of shuffling, so they tried running their shuffle twice. That was good enough to pass whatever test they used, so they went with it.

      --

      There's no point in questioning authority if you aren't going to listen to the answers.

    31. Re:damned faintly praising? by Annymouse+Cowherd · · Score: 1

      It would take a very unrandom Math.random() for this to happen.

    32. Re:damned faintly praising? by Bigjeff5 · · Score: 0

      What happens to the distribution when you run results through the function again?

      I ask because I just went to http://www.browserchoice.eu/ and tried it about 40 times and IE only came up in the last spot all of three times (I was watching it specifically because of your post). While it's certainly possible I flipped heads 37 times out of 40, it seems extremely unlikely. In fact, I got twice as many hits on the first position for IE than the last, and more often than not it was in one of the middle three positions.

      They start with the base list each time (you can see it briefly on the refresh), so in my opinion you haven't shown that running the flawed function a second time doesn't normalize the distribution adequately.

      The function they used seems perfectly acceptable for a random list of browsers.

      --
      Security is mostly a superstition... Avoiding danger is no safer in the long run than outright exposure. - Helen Keller
    33. Re:damned faintly praising? by asaz989 · · Score: 4, Informative

      Are you running Firefox? One of the things that the article points out is that the specific type of non-randomness that sort gives in this case is implementation-dependent (meaning browser-dependent). IE being pushed to the end is what happens in the Internet Explorer implementation of Javascript; the version of Firefox that he tested disproportionately pushes IE to the front, and presumably other browsers would give a different distribution.

    34. Re:damned faintly praising? by Dylan16807 · · Score: 1

      On a list 5 long, sure. But a bubble sort could would need a nearly-impossible sequence of trues for a list of even 100 items, since it does a new loop if a single item is unsorted.

    35. Re:damned faintly praising? by deniable · · Score: 1

      So the naive, 'better' solution would have been to generate a random key for each browser and then sort on that. Random and repeatable within the run and doesn't have any dodgy side-effects.

    36. Re:damned faintly praising? by Phantasmagoria · · Score: 5, Insightful

      If you had bothered to read the article, you'd see that the author has done JUST that. Not only did he prove (using proper statistical methods) that the results are significantly not random, he also dug up the exact javascript source code that does the shuffling and explained why it is faulty. RTFA!

      --
      Loban Amaan Rahman ==> Anagram of ==> Aha! An Abnormal Man!
    37. Re:damned faintly praising? by the_womble · · Score: 1

      Giving IE the rightmost position so often makes it look deliberate.

      There also seem to be a very high proportion of Trident based browsers. I count:

      5 Trident (IE, Green browser, Sleipnir, Avant, Flashpeak)
      3 Webkit (Safari, Chome, Maxathon)
      3 Gecko (FF, K-Meleon, Flock)
      1 other (opera)

    38. Re:damned faintly praising? by darkshadow88 · · Score: 3, Insightful

      This is obviously not a random distribution curve.

      I believe you meant to say uniform rather than random.

    39. Re:damned faintly praising? by mirix · · Score: 1

      Not to mention that a _truly random_ shuffle could play the same song ten times in a row. Not likely, but on a long enough scale it will happen.

      --
      Sent from my PDP-11
    40. Re:damned faintly praising? by TheLink · · Score: 1

      Do note that if you are using a nonIE browser to fetch that page, that page is pretty much irrelevant.

      --
    41. Re:damned faintly praising? by TheLink · · Score: 1

      > It's even more important in this particular scenario as the eye is generally drawn to the left or right most entry.

      Citation for "this scenario" please.

      Why wouldn't smack in the center of the screen be just as good or even better?

      My problem with the page is that on a slow connection/render, IE always shows up on the leftmost spot first, before the browsers being shuffled about.

      That to me is worse than how "unrandom" the algorithm is.

      --
    42. Re:damned faintly praising? by kmoser · · Score: 1

      It seems MS randomly selected the random-number generator. The next iteration will produce different results; you just need to wait for an alternate reality to see them.

    43. Re:damned faintly praising? by Jarjarthejedi · · Score: 1

      "This algorithm does push a certain browser higher more often than not, and hence is not fit for it's job."

      The job is to display a list of browsers in some order which cannot be known before the page is loaded. For that it succeeds perfectly. Does it really matter if certain browsers are favored over others? The entire list is going to be shown, so anyone who wants a specific browser can choose it anyway, and for the users that just click the first item in the list they're be getting relatively random (the #1 position was pretty close to random in the results).

      Perfect randomness is not needed everywhere. This was a pretty dumb mistake to make, but it's a very simple concept that doesn't require perfect randomness. Fit for the job != Perfect, and this algorithm seems to be perfectly fit for it's job according to the results.

      --
      There are two kinds of fool One says 'This is old therefore good' Another says 'This is new therefore better'- Dean Ing
    44. Re:damned faintly praising? by RobertM1968 · · Score: 1

      > It's even more important in this particular scenario as the eye is generally drawn to the left or right most entry.

      Citation for "this scenario" please.

      Wow, sounds like I am on Wikipedia... Slashdot does not require cites or even accuracy... c'mon, we all know that!!! ;-)

      Why wouldn't smack in the center of the screen be just as good or even better?

      Joking aside, you can look up various UI and reading (as in books) studies. You can look up eye tracking for advertising media and dig until you find studies... and you can look up how people who are "speed reading" fit that criteria... or a number of other related factors.

      It's also the reason why menus and ads are put on left and right (and/or top/bottom) of pages/UIs - the eye easily tracks to them.

      Does it apply to everyone? Probably not. But it supposedly applies to the vast majority of computer users. (supposedly as in, I did not conduct the studies, nor are the results mine)

    45. Re:damned faintly praising? by umghhh · · Score: 1

      If you read TFA you would know that the problem there is not only how random the results really are but that the used solution is just bloody pointless and utterly wrong. It also shows that albeit clueless these particular MS guys were also lucky enough not to break it in some other way (like crash every 10000 run of the 'radnom' routine etc) - something that TFA actually suggest could be possible.

    46. Re:damned faintly praising? by umghhh · · Score: 1
      why is this counterintuitive? M$ just used wrong solution to the problem. This shows that:
      1. they do not care about court ruling which is odd
      2. currently used browsers are robust enough to handle sort function that is broken like in our example
    47. Re:damned faintly praising? by Anonymous Coward · · Score: 0

      Here is original article from the Slovak site: http://www.dsl.sk/article.php?article=8770

      Both tables in the article are for 10000 runs, (it indicates percentage a browser will show on first to fifth position, then average place it earns). This comment

      http://www.dsl.sk/article_forum.php?action=reply&forum=260815&entry_id=657313&url=http%3A%2F%2Fwww.dsl.sk%2Farticle.php%3Farticle%3D8770

      shows statistics for 131K runs.

      Also, you have to note that each js implementation is a bit different, they calculated resultsin internet explorer 8, wich will be the browser used to show the ballot screen.

    48. Re:damned faintly praising? by Anonymous Coward · · Score: 0

      I forgot to say that first table in article is in IE8, but second is in firefox.. they made it to show the difference. The one in the comments is in IE8.

    49. Re:damned faintly praising? by Lennie · · Score: 1

      Who said the most to the left is best choice ?

      It's probably the one in the middle.

      --
      New things are always on the horizon
    50. Re:damned faintly praising? by Lennie · · Score: 1

      The browser-choice-screen is a windows update, maybe they'll also add an update to the IE random-number-generator. So maybe all these checks people are doing just don't tell you anything. Doubt it though. ;-)

      --
      New things are always on the horizon
    51. Re:damned faintly praising? by Lennie · · Score: 1

      (Thanks to another poster for finding the first google hit [slashdot.org] that describes this method.).

      I have a feeling, Microsoft employees are only allowed to use Bing for search. That might not work as well. ;-)

      --
      New things are always on the horizon
    52. Re:damned faintly praising? by TheLink · · Score: 1

      > It's also the reason why menus and ads are put on left and right (and/or top/bottom) of pages/UIs - the eye easily tracks to them

      I disagree. The real reason why menus and ads are put away from the center is because the center of the screen is normally reserved for the main content (e.g. the document, shell, or whatever the user is mainly working/playing with).

      --
    53. Re:damned faintly praising? by hairyfeet · · Score: 1

      Not to mention after the living shitfit the EU has thrown over past MSFT products like WMP (Windows N, anyone?) any algo they picked that had IE show up in the top three with any regularity would have probably resulted in another fit. The code they chose according to TFA has IE at dead last more than 50% of the time, so should get the EU off of their backs.

      This whole thing is nothing but a bureaucratic jerk off anyway, if you think about it. Imagine a user that is SOOOO stupid they need a "help me!" ballot box to pick a browser, because they are too damned dumb to type "Firefox" or "Chrome" into Google (hell my 67 year old dad went and downloaded his own Firefox, for the love of Pete) is actually gonna pick something that they know absolutely nothing about? Or are they gonna pick the big blue E that looks vaguely familiar, because that has been what they've been using since Win98?

      If I had to guess I would say Chrome will pick up a few, thanks to being Google, safari will keeping getting installed with iTunes, Firefox will stay on a slow and steady climb, and Opera will still be flat. They just don't have the buzz of the other three, nor the recognition of the big blue E, and I honestly think after all this browser hoopla it won't change the numbers for anybody enough to matter.

      --
      ACs don't waste your time replying, your posts are never seen by me.
    54. Re:damned faintly praising? by mr_lizard13 · · Score: 1

      'messing up pages shown to Opera'

      The code they used was supposed to randomise which browser got served the messed up HTML.

      Unfortunately the method they used favoured Opera more.

      --
      "We live in a global world" - Harvey Pitt, former Securities and Exchange Commission Chairman
    55. Re:damned faintly praising? by Lunix+Nutcase · · Score: 1

      No, the point was that no one browser got unfairly pushed to the top all the time

      Chrome?

    56. Re:damned faintly praising? by Anonymous Coward · · Score: 0

      wow, it puts IE in slot 5 a lot more often than it puts any other browser anywhere... I wonder if that was by design. Maybe Microsoft did a quick study and found that slot 5 was most likely to be picked, not slot 1, so they chose a random algorithm that'd stick IE there more often, while just appearing on its surface to be a crappy rand.

      But then again, that assumes a level of competency that Microsoft rarely displays.

    57. Re:damned faintly praising? by RobertM1968 · · Score: 1

      I'm not saying I agree or disagree with you. I did not do the studies.

  4. What's the problem? by Anonymous Coward · · Score: 3, Insightful

    What's the problem? It's random enough for a browser selection screen.

    This isn't an application where a statistically random shuffle is required.

    1. Re:What's the problem? by El+Lobo · · Score: 2, Funny

      Exactly, let's force them solve this problem with a .000000001 floating point precision. After all, this is a critical issue.

      --
      It's time to realise that Abble's products are the biggest abomination these days. Just say NO to the dumb iAbble way!!
    2. Re:What's the problem? by Anonymous Coward · · Score: 1, Informative

      You are missing the point.

      As the author of the article pointed out, this technique can cause an infinite loop.

    3. Re:What's the problem? by Anonymous Coward · · Score: 0

      How, exactly?

    4. Re:What's the problem? by TerranFury · · Score: 1

      Can it really? I can't come up with an example where this would occur with nonzero probability...

    5. Re:What's the problem? by EvanED · · Score: 3, Insightful

      As the author of the article pointed out, this technique can cause an infinite loop.

      For certain, pretty crappy definitions of "can". First, you'll notice he also points out that that "depends on the sorting algorithm used". I don't think that the most likely choices (Quicksort in particular) fall victim to this. Second, the other poster is right: the probability that it's actually an infinite loop is 0.

    6. Re:What's the problem? by Anonymous Coward · · Score: 5, Funny

      You are missing the point. As the author of the article pointed out, this technique can cause an infinite loop.

    7. Re:What's the problem? by ejtttje · · Score: 1

      It's not an academic issue of minor bias: the measurements show that IE winds up in slot 5 with 50% probability. That's hugely biased.

      And although some might shrug as the rightmost slot being somehow "bad", there are well known tendencies for people to remember the first and last thing in a list. The point of this whole ballot screen is to even the playing field to avoid this psychology stuff, and they missed the mark. Not to mention how bad it looks that they supposedly hire the best and brightest, but can't code a shuffle properly for a key component of a major lawsuit. WTF.

    8. Re:What's the problem? by Anonymous Coward · · Score: 0

      Depends on the sorting algorithm. Consider an algorithm which cycles through the array, swapping neighboring numbers which are in the wrong order, until no numbers need to be swapped (Bubble Sort). If the random function by chance returns a value which calls for swapping two elements in the array in every pass, then the algorithm never ends.

    9. Re:What's the problem? by QuoteMstr · · Score: 1

      .000000001 floating point

      There's no such thing. That number cannot be represented in IEEE binary floating point.

    10. Re:What's the problem? by EvanED · · Score: 1

      If the random function by chance returns a value which calls for swapping two elements in the array in every pass, then the algorithm never ends.

      The probability that happens is 0.

    11. Re:What's the problem? by Anonymous Coward · · Score: 0

      How, exactly?

    12. Re:What's the problem? by maxwell+demon · · Score: 1

      Of course, a legitimate implementation of quicksort could start with

      if (length > 1 && first element < second element && second element < first element)
        for(;;);

      Now, I don't see why anyone would do so, but it would give an accurate quicksort for any correct ordering, but an infinite loop with manifestly non-zero probability for the random result (25% per execution of those lines).

      --
      The Tao of math: The numbers you can count are not the real numbers.
    13. Re:What's the problem? by EvanED · · Score: 1

      IMO that sort of stuff falls into the "crappy definition of 'can'". I can't think of any remotely reasonable implementation of Quicksort that would have that behavior.

    14. Re:What's the problem? by Anonymous Coward · · Score: 0

      For any finite number k, the probability of the algorithm not ending before pass k is larger than zero. So, for practical values of "infinite loop", the probability is nonzero. Given a particular PRNG, the probability might even be nonzero for actual infinity.

    15. Re:What's the problem? by jim_v2000 · · Score: 1

      An infinite loop of what?

      --
      Don't take life so seriously. No one makes it out alive.
    16. Re:What's the problem? by Anonymous Coward · · Score: 0

      You are missing the point. As the author of the article pointed out, this technique can cause an infinite loop.

    17. Re:What's the problem? by Anonymous Coward · · Score: 0

      there're no precisions in shuffling. TFA points out that microsoft's algorithm sucks and you shouldn't shuffle that way. That's it

    18. Re:What's the problem? by Anonymous Coward · · Score: 0

      How, exactly?

    19. Re:What's the problem? by Anonymous Coward · · Score: 0

      How, exactly?

    20. Re:What's the problem? by pipatron · · Score: 1

      You are missing the point. As the author of the article pointed out, this technique can cause an infinite loop.

      --
      c++; /* this makes c bigger but returns the old value */
    21. Re:What's the problem? by Frater+219 · · Score: 1

      The point of the article is not to accuse Microsoft of wrongdoing. It's to use a highly visible example -- a screen that will be presented to every Windows user in Europe! -- to teach a computer science lesson to programmers.

    22. Re:What's the problem? by EvanED · · Score: 1

      So, for practical values of "infinite loop", the probability is nonzero.

      Yeah, but it's equally true that it's pretty clear that the probabilities of it going a while are very low. I mean, this guy did probably tens of thousands of tests; if there was even a half decent chance of one of them taking a while he'd have noticed.

      Long story short:
      - Not an infinite loop by a theoretical sense
      - Not really an infinite loop by a practical sense

    23. Re:What's the problem? by wideBlueSkies · · Score: 1

      How, exactly?

      --
      Huh?
    24. Re:What's the problem? by wideBlueSkies · · Score: 1

      Instructions.

      --
      Huh?
    25. Re:What's the problem? by ooshna · · Score: 1

      That's how

    26. Re:What's the problem? by mestar · · Score: 1

      Well, there's this theory:

      http://www.youtube.com/watch?v=QER_yqTcmjM

    27. Re:What's the problem? by Anonymous Coward · · Score: 0

      give it up

    28. Re:What's the problem? by asaz989 · · Score: 1

      A browser selection screen has a lot of money behind it (remember the billions of dollars of euros Microsoft got fined for lack of something like this?) If this non-random behavior slightly changes the proportions so that IE is (on average) favored by customers, their competitors lose out. If IE is on average selected less often than it would be with a really random shuffle, then that's money Microsoft is losing. Whichever way, it matters.

    29. Re:What's the problem? by Dylan16807 · · Score: 1

      You did notice that this test case is only 5 items, right? Even bubble sort can escape this in ~16 cycles, let alone a proper sort. But you could have a fast sort that needs consistent data or it'll get stuck on a large data set.

    30. Re:What's the problem? by EvanED · · Score: 1

      Who cares about how it behaves on a larger data set? The point is that, if it weren't for the non-uniformity in the results, it'd be fine for what they have.

    31. Re:What's the problem? by skelterjohn · · Score: 1

      If the probability of an algorithm going into an infinite loop is zero, then it can't go into an infinite loop.

    32. Re:What's the problem? by MadnessASAP · · Score: 1

      Unless you're using 8 bit floats (Which isn't IEEE standard) I find your claim highly suspect.

      --
      I may agree with what you say, but I will defend to the death your right to face the consequences of saying it.
    33. Re:What's the problem? by GreyWolf3000 · · Score: 1

      You remind me of the babe.

      --
      Slashdot: Where people pretend to be twice as smart as they really are by behaving like children.
    34. Re:What's the problem? by Quantumstate · · Score: 1

      Using binary floating points you will find that you cannot store exact powers of 10. So it would be very close of 0.000000001 but would not be exactly the same.

    35. Re:What's the problem? by MadnessASAP · · Score: 1

      Well I was about to prove you wrong but while actually reading the IEEE standard I ended up proving myself wrong.

      --
      I may agree with what you say, but I will defend to the death your right to face the consequences of saying it.
  5. Cheating at online poker by EvanED · · Score: 0, Offtopic

    There were some folks a while ago who wrote up a security investigation they did of Party Poker's site.

    One of the problems they had was a terrible, non-uniform shuffling algorithm. Completely different problem than what MS did, but interesting nonetheless. (I actually guessed that this is what MS did, but that's not the case.)

    1. Re:Cheating at online poker by EvanED · · Score: 1

      they did of Party Poker's site.

      Shit, PlanetPoker, not Party Poker. Sorry.

  6. Yeah right by CSHARP123 · · Score: 2, Insightful

    Showing a browser selection has been imposed on them and these geeks think MS is going to select the best approach possible for randomness. No wonder none of you are sucess in business.

    1. Re:Yeah right by TerranFury · · Score: 1

      1 - You didn't read the article, did you?

      2 - Although their method for generating uniformly-random permutations is incorrect, they are doing nothing to favor IE.

    2. Re:Yeah right by girlintraining · · Score: 1

      Showing a browser selection has been imposed on them and these geeks think MS is going to select the best approach possible for randomness.

      I don't believe many of them think that, judging by the comments so far. I think they're incredulous that a multibillion dollar company that has been developing software since the dawn of the information era managed to screw up a rather basic computer science problem. Given a lack of indication as to motive, they've decided to jump to whatever conclusion fits their personal biases best, which is what happens in every argument when there aren't enough facts to conduct a proper analysis.

      Just because you've got a forum full of people who spend their days working with machines that answer everything with either 1 or 0, doesn't mean they've learned anything from the interaction and incorporated it into their own thought processes.

      --
      #fuckbeta #iamslashdot #dicemustdie
    3. Re:Yeah right by CSHARP123 · · Score: 1

      You don;t need perfect solution for every problem is what I am saying. Thats just waste of time. A geek is the only one who will try for that not a successful business.

    4. Re:Yeah right by WalksOnDirt · · Score: 1

      I suspect it would have been faster to look up a correct algorithm and implement it than think up this hack. Who ever came up with this was just incompetent.

      --
      a,e,i,o,u and sometimes w and y (at be if of up cwm by)
    5. Re:Yeah right by Anonymous Coward · · Score: 0

      "I think they're incredulous that a multibillion dollar company that has been developing software since the dawn of the information era managed to screw up a rather basic computer science problem."

      Companies don't write software, people do.

    6. Re:Yeah right by girlintraining · · Score: 1

      A geek is the only one who will try for that not a successful business.

      Apparently well-designed and engineered products make for bad business. Why, imagine if the customers found out something had been well-designed and was beyond criticism or reproach! Why, who would buy such a thing?

      --
      #fuckbeta #iamslashdot #dicemustdie
  7. Good enough by TBoon · · Score: 1, Insightful

    Given that each user is only going to see this screen once per computer, I'd say simply using the seconds of the current minute as a random seed should be OK. Can't see why you would need more randomness that that in this particular situation. Just make sure that the distribution of browsers evens out for all seeds...

    1. Re:Good enough by EvanED · · Score: 4, Informative

      Given that each user is only going to see this screen once per computer, I'd say simply using the seconds of the current minute as a random seed should be OK

      This problem has nothing to do with how the PRNG is seeded.

      The word "seed" doesn't even appear in TFA at all.

    2. Re:Good enough by Anonymous Coward · · Score: 0

      *woosh*

    3. Re:Good enough by Anonymous Coward · · Score: 0

      *woosh*

    4. Re:Good enough by mangu · · Score: 4, Insightful

      Given that each user is only going to see this screen once per computer

      Given that each person will only lose one cent per lifetime, I propose to move $0.01 from each bank account in the world to my own account.

    5. Re:Good enough by Anonymous Coward · · Score: 1, Funny

      Given that each user is only going to see this screen once per computer

      Given that each person will only lose one cent per lifetime, I propose to move $0.01 from each bank account in the world to my own account.

      That must be the most accurate and incredible insightful analogy to the issue at hand I've ever seen that doesn't involve cars.

    6. Re:Good enough by maxume · · Score: 1

      The interesting thing there is that it would only be a great deal of money, you wouldn't be particularly wealthy (in a relative sense).

      --
      Nerd rage is the funniest rage.
    7. Re:Good enough by mattack2 · · Score: 1

      Given that each user is only going to see this screen once per computer,

      Tangential question (not nitpicking) - isn't it really once per user? Those of us that actually use multiple users may have to answer it multiple times. (I'm on OS X, but I'm still curious.)

    8. Re:Good enough by MSesow · · Score: 1

      I am all for this, so long as you are fair about it. To be fair, we need to do this for every account on the planet, though. Also, I have to agree that using the current second seems random enough, given that each person's arrival at the choice should be random for the value of the second. Since there are 120 permutations, you could store it in an array on a server, and then the client, when ready to look at the choice, takes the current second, plus sixty if the minute is odd, and does a look-up of that location in the array. The cost of doing this for everyone would be pretty light - one mod, one addition and one request across a network; server has only a single look-up per request to do. I think this works under the assumptions that people will randomly arrive at the choice over a two minute period (I can't see why they wouldn't). I also wondered if you need to randomize the array, but if the people's requests are timed at random I don't think you do. This should even pass the test the author uses if there is two-, four-, etc. minute run time; if there is a large run time, like an hour; probably not for short, odd minute run times, and not if the assumption about random arrival times is wrong.

    9. Re:Good enough by Anonymous Coward · · Score: 0

      *woosh*

    10. Re:Good enough by Anonymous Coward · · Score: 0

      Okay, but you're going to have to pay for the shipping.

    11. Re:Good enough by drawfour · · Score: 1

      I have more than one bank account, you insensitive clod!

    12. Re:Good enough by kramerd · · Score: 1

      Given that each user is only going to see this screen once per computer

      Given that each person will only lose one cent per lifetime, I propose to move $0.01 from each bank account in the world to my own account.

      Sorry, that solution isn't random (even if it does solve the issue of uniformity).

    13. Re:Good enough by Anonymous Coward · · Score: 0

      Not good, that will give 60 different possible outcomes, but the total number of ways to order 5 things is 5! = 120.

  8. Milliseconds by Lord+Lode · · Score: 2, Interesting

    They could as well just have used the last millisecond to show the browser. I mean, it's a screen shown only once to a user. What's more random, and uniform, than the time the screen appears in milliseconds modulo 5?

    1. Re:Milliseconds by SpinyNorman · · Score: 2, Informative

      It's not an issue of how to get a truly random number, or of seeding a random number generator, but rather how to you use a source of random numbers to randomly order a list.

      Some "reasonable sounding" methods don't actually work - e.g. attach random numbers to each list item and sort the list by these numbers (1). Microsoft used a similar method of sorting using a random comparator.

      Some simple methods that DO work are picking a random permutation or executing a bunch of random swap operations on the list.

      (1) http://okmij.org/ftp/Haskell/perfect-shuffle.txt

    2. Re:Milliseconds by Jorl17 · · Score: 1

      That'd be the same problem! The thing is not the randomness of the number but how they use it!

      --
      Have you heard about SoylentNews?
    3. Re:Milliseconds by ejtttje · · Score: 1

      The task requires more than picking a single random number, the task is to generate a random ordering of elements. Doing this correctly is not simply a matter of choosing a seed for the PRNG, if that is what you are referring to. Where Microsoft has screwed up is applying a randomized comparison function to a sort operation. This does not yield anything close to a uniform distribution depending on the sorting algorithm being used. (Thus the test results showing 50% probability of IE in slot 5!)

      Instead, FTFA one of the good solutions is to iterate backwards through the list, swapping the current element with a randomly chosen element earlier in the list.

    4. Re:Milliseconds by Lord+Lode · · Score: 1

      Ok, sorry, had read only the summary when posting this. Should have read the full article first...

    5. Re:Milliseconds by Ambiguous+Puzuma · · Score: 1

      Some "reasonable sounding" methods don't actually work - e.g. attach random numbers to each list item and sort the list by these numbers (1).

      That method does work as long as you guarantee the uniqueness of the random numbers--in other words, a tie shouldn't mean leaving elements in place, but rather repeating the algorithm on each subset of the list where the random numbers came up equal.
      I see no advantage to it over the Fisher-Yates shuffle (which should be the default solution to the problem), but it can be made to work.

    6. Re:Milliseconds by marcansoft · · Score: 1

      Attaching random numbers to each list item and sorting does work for all practical purposes, as long as you use a reasonably large set of possible random numbers (e.g. a 32-bit float, not a one-bit integer as your worst-case example mentions). What Microsoft did is far worse: abuse a black box sort function by violating the specification for the compare function, and somehow assume that this black box will spit out random results. The former will never be truly mathematically optimal (which is the point of the article you cite), but it will be plenty good enough (probably indistinguishably so from a perfect one) in 99% of non-deliberately-broken implementations (to the point where you start caring about Math.Random itself). The latter is pretty much guaranteed to fail catastrophically, as we see here.

      It's worth noting that neither picking a random permutation nor performing a bunch of random swap operations are likely to be mathematically ideal unless you have a random number generator capable of producing perfectly uniform random numbers within an arbitrary range (and this is basically the same kind of issue that you get when attaching numbers and sorting). Long story short, unless your total randomness utilized is essentially represented as a number that's a multiple of the number of permutations of what you're shuffling, you're going to get some (usually extremely minor) roundoff biases.

    7. Re:Milliseconds by maxwell+demon · · Score: 1

      That method does work as long as you guarantee the uniqueness of the random numbers--in other words, a tie shouldn't mean leaving elements in place, but rather repeating the algorithm on each subset of the list where the random numbers came up equal.

      If the range of numbers is sufficiently large (as should be typically the case when generating pseudo random numbers in the [0,1) range) then the probability of two numbers being the same is small enough to be statistically negligible.

      --
      The Tao of math: The numbers you can count are not the real numbers.
    8. Re:Milliseconds by SpinyNorman · · Score: 1

      No - look at the example of the two-element list in the link I provided. I'll copy it here for convenience:

      A commonly used shuffle algorithm attaches random tags to elements
      of a sequence and then sorts the sequence by the tags. Although this
      algorithm performs well in practice, it does not achieve the perfect
      random shuffling.

      Let us consider the simplest example (which happens to be the worst
      case): a sequence of two elements, [a b]. According to the
      shuffle-by-random-keys algorithm, we pick two binary random numbers,
      and associate the first number with the 'a' element, and the second
      number with the 'b' element. The two numbers are the tags (keys) for
      the elements of the sequence. We then sort the keyed sequence in the
      ascending order of the keys. We assume a stable sort algorithm. There
      are only 4 possible combinations of two binary random
      numbers. Therefore, there are only four possible tagged sequences:

      [(0,a) (0,b)]
              [(0,a) (1,b)]
              [(1,a) (0,b)]
              [(1,a) (1,b)]
      After the sorting, the sequences become:
              [(0,a) (0,b)]
              [(0,a) (1,b)]
              [(0,b) (1,a)]
              [(1,a) (1,b)]

      As we can see, after the sorting, the sequence [a, b] is three times
      more likely than the sequence [b, a]. That can't be a perfect shuffle.

      **

      The example is assuming that of the two random numbers, a b - not a == b.

      Never mind the theory, look at the results from TFA. IE was in 5th place (out of 5) 50% of the time in a large statistically meaningful result set.

    9. Re:Milliseconds by Anonymous Coward · · Score: 0

      Good idea. There are 5! == 120 permutations, which is not a fatal flaw.

      See my equivalent comments from Feb 24th in the "fast comments" section of http://motls.blogspot.com/2010/02/microsoft-browser-lottery-do-js-random.html

      - Shawn

    10. Re:Milliseconds by Ambiguous+Puzuma · · Score: 1

      The only reason what you quoted doesn't work is because in the case of a tie (50% of the time), it is using the initial ordering. That is the source of bias in your example, and it is avoidable.

    11. Re:Milliseconds by harlows_monkeys · · Score: 1

      Ambiguous Puzuma wrote:

      That method does work as long as you guarantee the uniqueness of the random numbers--in other words, a tie shouldn't mean leaving elements in place, but rather repeating the algorithm on each subset of the list where the random numbers came up equal

      You responded

      No - look at the example of the two-element list in the link I provided. I'll copy it here for convenience:

      Puzuma is right. The example you provide does not guarantee uniqueness. In the four cases is analyzes, two of them involve assigning the same random number to both elements.

      In practice, this is not a problem when shuffling a small array, because most people use a random number generator with more possible outputs than the 1/0 used in that example. If your random number generator has a range of [0, 2^32-1], for instance, then you'll end up with non-unique sort values about once every 400 million shuffle attempts. That's good enough for most applications.

      As Puzma notes, you can fix this by noting elements that are assigned the same random number and repeating the process on them. Here's a Perl implementation that does that:

      sub randomize_array(@)
      {
      my @out;
      my %h;
      map {push @{$h{rand()}}, $_} @_;
      map {push @out, @{$h{$_}} == 1 ? $h{$_}[0] : randomize_array(@{$h{$_}})} keys %h;
      return @out;
      }

      Even if you were to restrict the random number generator to just returning 0 or 1 (by changing rand() to int(rand(2))), the above will produce properly shuffled arrays.

    12. Re:Milliseconds by SpinyNorman · · Score: 1

      No - look at the data from top of TFA (those two tables). IE was in 5th place 50% of the time vs what should have been 20% if it had been random..

      It was a large statistically meaningful sample. The problem here isn't round-off or a poor random number generator. It's using an invalid list randomize algorithm.

      Getting random numbers evenly distributed over an arbitrary range isn't a problem as long as you've got them available evenly distributed over *some* range. You just scale them.

    13. Re:Milliseconds by Anonymous Coward · · Score: 0

      Your source gives a pitfall for attaching random numbers which you interpret as debunking the method in its entirety. All that is required is that the assignment be UNIQUE random numbers to each list item. This is trivial if you choose if you choose a sample space of M > n^2, where n is the number of items you want to randomize and mark each number as it is used or maintain a sorted list of used numbers - the expected number of collisions is less than 0.5 and the memory constraints are order M (respectively n) and run time is O(1) (respectively O(log n)). Either is a trivial alteration in the case of n = 5.

      In a situation where you are randomizing 5 numbers, the probability of rand() assigning the same random number to two options is effectively 0 (Even if we were only using 16 bit numbers rather than the more likely 32 or 64 bits, the probability of two or more random numbers being the same is less than 5_C_2 x 2^-16 or roughly 1.53 x 10^-4. For 32 bit, the probability is less than 2.33 x 10^-9, and for 64 bit the probability is less than 5.42 x 10^-19. In any of these situations, you are within 0.1% of the correct probability for each position. In either the 32 or 64 bit random number cases (the more likely cases with 32 and 64 bit chips) the expected number of computers with Internet Explorer occupying each position would only differ by a few computers, or possibly 1 when rounded to whole numbers respectively, even if everyone in Europe installed Windows 7.

    14. Re:Milliseconds by socsoc · · Score: 2, Insightful

      Yep

    15. Re:Milliseconds by marcansoft · · Score: 1

      Microsoft did not attach random numbers to each entry in the list. That does work. What Microsoft did is return random results for a compare function. There's a big difference there, because in the former case the compare function will return consistent, coherent results for a randomized list, while in the latter case the compare function will return random, inconsistent, meaningless results. You might see some similarity there (use of a sorting function), but the algorithms are completely different, and only Microsoft's is horribly broken.

      All I'm trying to say is that the .txt file that you cited is talking about academically ideal randomness and stuff that doesn't really apply here, because, although sorting a list by some form of binary random numbers will always have a tiny roundoff bias (lower the bigger the number you use), that kind of minimal bias is completely irrelevant in pretty much all real world uses. Microsoft's problem is different, and although their method is related, the problem that they have has nothing to do with what the .txt file explains.

    16. Re:Milliseconds by Quantumstate · · Score: 1

      Attaching random numbers does work assuming you resolve cases where two items get assigned the same random number by repeating the random number assignment. This is obvious because assigning the random number is completely independent of the position of the number in the list (assuming a good random number generator). Therefore the problem si completely symmatrical so there can be no bias.

    17. Re:Milliseconds by Anonymous Coward · · Score: 0

      Some "reasonable sounding" methods don't actually work - e.g. attach random numbers to each list item and sort the list by these numbers (1).

      This method isn't as bad as you make it out to be as long as the probability of assigning the same random number to any two (or more) items in the list is small enough. With only 5 items to sort and a random number generator that produces "good enough" 32 bit numbers, it's actually pretty good.

      Microsoft used a similar method of sorting using a random comparator.

      Microsoft's algorithm is not similar at all with any non-trivial sorting algorithms, since the result of a comparison against one element will be assumed to imply a certain outcome when compared with other elements which are already known to compare to the first element in a certain way. E.g. if you have already established that a>b>c, and you just found out that c>d, there's no need to compare d and b or d and a. This is the reason why IE is last in the list with 50% probability, since it is apparently compared with the (then) last item in the list and is greater than that in 50% of the cases.

  9. Re:What? Why not? by EvanED · · Score: 5, Insightful

    Why not? Is the author suggesting that random functions in use today are somewhat deficient? What is his solution?

    You know, it's really too bad that the author of the article the summary linked to didn't write up an article answering exactly that. Then maybe Slashdot could have linked to it.

    (In a nutshell, the answers are, respectively: "because plopping a 'rand()' into your code doesn't mean that what you'll get out is uniform", "no", and "use a shuffling algorithm that works.")

  10. I have been fired for less. by bezenek · · Score: 0, Troll

    People like the higher-ups at Microsoft (or most companies, I believe) do not care or want to hear about these issues.

    If it does not involve a bonus (for the executive) or making them look good (the executive), engineers have to shut up and smile.

    -Todd

    p.s. Of course, this is my opinion--not what I would do, and it goes against good ethics. But, who in Silicon Valley cares about ethics? :-|

    --
    Omne ignotum pro magnifico.
    1. Re:I have been fired for less. by QuoteMstr · · Score: 1

      You need to stop working for this guy.

      And yes, I'm also seriously disturbed by careless attitude of many in the Bay Area and Silicon Valley --- I've had a chance to get to know the area better lately.

    2. Re:I have been fired for less. by omfgnosis · · Score: 1

      Or Redmond for that matter? 9_9

    3. Re:I have been fired for less. by bezenek · · Score: 1

      People like the higher-ups at Microsoft (or most companies, I believe) do not care or want to hear about these issues.

      If it does not involve a bonus (for the executive) or making them look good (the executive), engineers have to shut up and smile.

      -Todd

      p.s. Of course, this is my opinion--not what I would do, and it goes against good ethics. But, who in Silicon Valley cares about ethics? :-|

      Why are people marking this as a troll?

      As far as I know, it is true.

      I suppose my comment, "But, who in Silicon Valley cares about ethics?" is a bit of a troll, but based on reality. For example:

      I was offered a job. The HR department at the company pressed me to make a decision about taking the job. As a result, I lost the opportunity to play-out the interview process for a much better position.

      When I described this tough problem to a well-known Silicon Valley CEO, he said I should have taken the job (as I did), kept up the interview process with the other company (I told them I was taking another job), and then quit the job I took if the better one panned out. He specifically said he had done the same thing, which involved working at a company for 1.5 weeks and then quitting for a better offer.

      Maybe it is just me, but this seems wrong. But, in Silicon Valley, it appears to be business-as-usual.

      -Todd

      --
      Omne ignotum pro magnifico.
  11. The top hit on Google... by jmtpi · · Score: 5, Interesting

    A Google search on:

    javascript array sort

    gives exactly the bogus answer that Microsoft used in the top hit.
    Unfortunately for Microsoft, a bing search gives the same top hit.

    1. Re:The top hit on Google... by Anonymous Coward · · Score: 2, Informative

      On the other hand, searching for 'javascript array shuffle' returns the correct solution in almost every hit in the first page in Google (wrong answer comes on top in Bing, but the second hit is correct).

    2. Re:The top hit on Google... by VoltageX · · Score: 1

      I wonder if it's worth it in this case to let the top site know that their information isn't great.

      --
      "Anonymous could not immediately be reached for further comment." - International Business Times
    3. Re:The top hit on Google... by gargleblast · · Score: 1

      Its too bad the programmer didn't even know he was looking for a "shuffle". The top two hits for javascript shuffle get it right and even refer to Fisher-Yates.

  12. Re:What? Why not? by Tapewolf · · Score: 5, Informative
    I thought it was originally going to be that they forgot to seed the random number generator or something.

    What the problem actually seems to be is not that they're using random, but how they're using it.

    What they essentially did was use something like qsort() to sort the list, but in their comparator function, instead of returning which of the two strings comes first, they return some random crap instead. qsort() or whatever they used was designed to have results that are consistent, and with input like that it could potentially abort and leave the list entirely unsorted. Or if you're really unlucky it could sit there sorting them forever.

  13. Microsoft problem solving by gmuslera · · Score: 1, Funny

    There are 5 well-known approaches: 3 good solutions, 1 acceptable solution that is slower than necessary and 1 bad approach that doesn’t really work. Microsoft appears to have picked the bad approach.

    We are still talking here about the random selection of browsers, or something more broad?

    1. Re:Microsoft problem solving by Anonymous Coward · · Score: 0

      It's talking about algorithms for creating a random permutation.

      Another common example of this problem is creating a fair shuffle of a pack of cards. If your poker machine is going to pass the gaming board, it's going to have to do it correctly...

    2. Re:Microsoft problem solving by omfgnosis · · Score: 1

      I think that is actually describing the browsers themselves.

  14. Amateurs... by Anonymous Coward · · Score: 0

    ...they should ask the Debian folks.

  15. random number generator by Anonymous Coward · · Score: 0

    ... nine nine nine nine nine nine ...

    http://dilbert.com/strips/comic/2001-10-25/

  16. Um, yeah by oldhack · · Score: 0, Troll

    Microsoft was so grateful, because Microsoft cares.

    --
    Fuck systemd. Fuck Redhat. Fuck Soylent, too. Wait, scratch the last one.
  17. He's just bitching by Sycraft-fu · · Score: 4, Insightful

    It is probably a combination of two things:

    1) Hate for MS. MS is doing what some have said they've needed to do in giving users browser choice, and they've done so as to try not to promote any given one. While that makes proponents of choice happy, it makes MS haters mad. The more MS does to try and accommodate users and play fair, the less there is to hate on them for legitimately. As such haters are going to try and find nit picks to bitch about.

    2) General geek pedantry. Many geeks seem to love to be exceedingly pedantic about every little thing. If a definition isn't 100% perfect, at least in their mind, they jump all over it. I think it is a "Look at how smart I am!" kind of move. They want to show that they noticed that it wasn't 100% perfect and thus show how clever they are.

    Doesn't matter, it is what it is and as you said, random enough. This guy can whine all he likes.

    1. Re:He's just bitching by magsol · · Score: 4, Insightful

      On the other hand, the devil is in the details, and one would think that a company such as Microsoft that has been owning the software market for decades now would know how to implement a randomizing algorithm correctly.

      --
      "I'd just like to emphasise that taking a million years isn't a metaphor here..." -Rich Bradshaw
    2. Re:He's just bitching by AdmiralXyz · · Score: 3, Insightful

      one would think that a company such as Microsoft that has been owning the software market for decades now would know how to implement a randomizing algorithm correctly.

      Wrong: a software company such as Microsoft that has been owning the software market for decades now knows how to use programmer time and resources effectively. Spending the extra programmer time and effort to turn a "99.99% random" process into a "100% random" one is an utter waste of both on something this trivial. Hate to break it to you, and to look-at-me-I'm-so-much-smarter-than-evil-Microsoft Rob Weir, but they're not making any mistake here.

      --
      Dislike the Electoral College? Lobby your state to join the National Popular Vote Interstate Compact.
    3. Re:He's just bitching by TerranFury · · Score: 4, Insightful

      Whatever. They offloaded what looked like a menial task to some low-level programmer, who ran it a few times, saw it was "random" (without doing any statistical tests), and went home happy. He probably should have known the Knuth shuffle algorithm -- I remember studying it in high school CS, even -- but honestly it's not that huge a deal.

    4. Re:He's just bitching by MaskedSlacker · · Score: 1

      To be fair, this is more like 60% random, not 99.99%.

    5. Re:He's just bitching by lennier · · Score: 2, Funny

      On the other hand, the devil is in the details, and one would think that a company such as Microsoft that has been owning the software market for decades now would know how to implement a randomizing algorithm correctly.

      Sure!

      10 RANDOMIZE TIMER
      20 PRINT INT(RND * 5)
      30 GOTO 20

      --
      You are not a brain: http://books.google.com/books?id=2oV61CeDx-YC
    6. Re:He's just bitching by DavidShor · · Score: 2, Insightful

      Did you read the god-damn article? The results are insanely non-uniform. With a sample-size of 10,000 , IE ends up in 5th place 50% of the time. I mean, it's not evil, it doesn't benefit them. But it makes them look insanely dumb.

    7. Re:He's just bitching by maxwell+demon · · Score: 4, Interesting

      Spending the extra programmer time and effort to turn a "99.99% random" process into a "100% random"

      I don't know what you consider "99.99% random", but the difference between 20% (probability of IE turning up last in a real random shuffle) and ca. 50% (probability of IE showing up last in the implemented "random shuffle") is certainly significant enough that you can't call it 99.99% random." You might argue that it is "random enough for this," but that's of course a matter of opinion, and therefore debatable (there's no objective definition of "random enough").

      --
      The Tao of math: The numbers you can count are not the real numbers.
    8. Re:He's just bitching by Short+Circuit · · Score: 2, Insightful

      It's paranoia and naiveté like yours that led me to stop hanging around here so much.

      Paranoia in that everything company X does is evil or has an inappropriate or immoral ulterior motive. Naiveté in that you don't stop to recognize that the not all of the developers who work for an institution are going to output code of the caliber of its most senior, experienced and/or knowledgeable developers, nor can code review and automated tests catch all of the problems and gotchas known to computer science, academia and the body of professional programmers.

      So can the "the devil is in the details" crap; you don't know what you're talking about. Building a complex software package that takes into account every possible detail in both process and implementation is impossible in any environment currently available for consumer software and general computing hardware. Just when you think you've got everything covered, nature builds a vendor builds a buggy component, security specialists discover a flaw in the way you learned to write your software, nature builds a better idiot, or a piece of a radioactive isotope in a memory module emits a beta particle, just to ruin your day.

    9. Re:He's just bitching by Anonymous Coward · · Score: 0

      2) General geek pedantry.

      I'm all for it. Just could we also go after silly coding in popular Linux distros? Not just to be evenhanded, but to improve the breed.

      Given: MS is under a lot of righteous suspicion when it comes to playing fair, and putting this article on /. quashes what would have been heavy rumours that the browser selection was not random. That's good.

      Let's just shine the light further. Maybe every other Sunday run a /. post like "What's your current face-palm about distro ____?"

    10. Re:He's just bitching by 644bd346996 · · Score: 3, Insightful

      They made the stupid mistake of not assigning an experienced or well-educated programmer to a project that was necessary for them to legally do business in Europe. Somewhere along the way, the legal department had to have sent the technical managers an email containing a phrase very similar to "don't fuck this up!!", and the manager ignored it and assigned a programmer who didn't go to a good CS school and thus has never heard of a Fisher-Yates shuffle or something equivalent.

      It's very understandable that some of Microsoft's programmers are of such low quality. What is odd is that their legal department can't make their technical managers understand "do this right or we lose the right to do business on the second most profitable continent."

    11. Re:He's just bitching by Anonymous Coward · · Score: 0

      a software company such as Microsoft that has been owning the software market for decades now knows how to use programmer time and resources effectively.

      You'd have hoped so, eh?

      What about Windows Vista? Hundreds of man-years of effort and billions of develoment costs down the shitter. Oops!

      Microsoft actually has a notiously bad internal culture full in infighting between competing groups.

    12. Re:He's just bitching by magsol · · Score: 1

      I don't know why you're coming down so hard on this, particularly since you are absolutely correct. My point was that Microsoft knows how to implement a trivial randomization algorithm in a trivial situation (the difference between 60% and 100% random in this situation is not only unobservable unless thousands of iterations are performed, but it's also trivial to close that gap). If they went with a less-random algorithm, it would be far more likely to have been a willful decision instead of an accidental mistake. We're making two different and non-overlapping points.

      --
      "I'd just like to emphasise that taking a million years isn't a metaphor here..." -Rich Bradshaw
    13. Re:He's just bitching by omfgnosis · · Score: 1

      there's no objective definition of "random enough"

      Of course there is: "sufficiently random for the task in question". It's objective, but useless, because it depends on "sufficient" and "the task in question" to be specified, and neither are.

    14. Re:He's just bitching by pla · · Score: 1

      2) General geek pedantry. Many geeks seem to love to be exceedingly pedantic about every little thing. If a definition isn't 100% perfect, at least in their mind, they jump all over it. I think it is a "Look at how smart I am!" kind of move. They want to show that they noticed that it wasn't 100% perfect and thus show how clever they are.

      First of all, let me say that I fall in on Microsoft's side on this one - So they didn't use a shuffle that would pass muster for a licensed video poker system - So what? Totally irrelevant, they satisfied the obligation to randomize the list, end of story.

      However, as to your comment about geek pedantry - I often get accused of doing exactly what you say, and can say comfortably that I don't do it to "look smart". I do it because if you bother defining a term, then immediately contradict yourself, we have a real problem. To a lesser degree, if you use a normally well-defined term incorrectly, then again, we have a problem.

      I think geeks pick nits about such matters more for clarity than for self gratification. And I defend that stance by the fact that I demand similar precision from myself... If, in a conversation, I start down a path that leads to a contradiction, I will apologize, see if my intended point still holds despite the misstart, and proceed from there.

      The fact that this habit tends to annoy others, I attribute to the fact that, in demanding such rigor from ourselves, we get fairly good at not making such errors all that often - Thus we seem to pick nits about others, but not ourselves.

    15. Re:He's just bitching by Anonymous Coward · · Score: 0

      Funny thing, I've seen this exact bug in Apache Foundation's email server project. It caused DNS MX records to be used in far from the random order required by the RFC. Now that has some real network load-balancing implications. Anyone want to whine about the evilness of Apache, and their non-compliance with standards?

      But still - it's an interesting bug to be aware of.

    16. Re:He's just bitching by Anonymous Coward · · Score: 0

      Sorry, no. That algorithm is neither simpler nor faster than a correct solution and it is nowhere near 99.99% random. On IE, it puts IE in position 5 four times as often as any other position and it puts Chrome in position 1 twice as often as IE. We might let this one slip, because apparently Microsoft does itself a disservice, but it's still not even remotely a proper randomization. If this is the quality of code which Microsoft produces when the source is visible, what do they put where people can't take a peek?

    17. Re:He's just bitching by omfgnosis · · Score: 1

      I'm not convinced it doesn't benefit them. I'm betting that eye-tracking tests would show a disproportionate amount of attention to the last position, at least over the middle positions but possibly over the first as well. This hunch is founded on a tendency in UI design to place useful things (eg search and navigation) on the right and an expectation that users have grown accustomed to this.

    18. Re:He's just bitching by 1+a+bee · · Score: 1

      Agreed. The blogger's article is a bit pointless: he can't show a bias in favor of any one browser; he only shows that there is a non-random distribution. Perhaps with a bit more analysis he could have determined if any of the browsers in fact did enjoyed a bias. That would have been interesting, but as it stands, the article is little more than supercilious pedantry.

    19. Re:He's just bitching by cgenman · · Score: 5, Insightful

      While in Microsoft's native browser (which would happen the first time), Internet Explorer is given a full %64 chance of receiving one of the coveted 2 edge positions. Considering that antitrust courts were involved in the creation of this screen, you'd think that getting "random" right would be a development priority, especially considering it should have taken a competent programmer exactly the same amount of time to do it right as to do it wrong. If this takes even one hour of lawyer time to ponder, it would have been much cheaper to send the programmer back to fix it.

      A 50% chance of getting a particular slot that should be %20 is not "99.99% random." It's just wrong. And when you're talking about the cost of antitrust regulation, it's really, really wrong.

      I'm glad this is being brought up on Slashdot. There is a lot of misunderstanding about how to create randomness in systems. Even on a basic level, people frequently ask for "random" when they actually want jukebox random. In this case, though, it just seems like a basic misunderstanding of statistics, which is not surprising given the moderate code complexity and likelihood this screen was given to an intern or jr programmer.

    20. Re:He's just bitching by bmcage · · Score: 2, Insightful
      Do you have any mathematical or logical inclination?? Well I have, and seeing such a stupid way to randomize 5 entries just makes me weep! Be truthfull here, would _you_ program it that way?? What are they smoking in Seattle?

      And as the article says, if you use statistics to determine if the program is random, then the answer will be ... not random. So please, don't call this random, and if you do, please, let me know which software you work on, so I can avoid it.

      I agree that all this does not matter for the ballot screen. But at least on slashdot we can expect some higer standards than a

      return (0.5 - Math.random());

      comparison function.

    21. Re:He's just bitching by sohp · · Score: 1

      So they didn't use a shuffle that would pass muster for a licensed video poker system - So what? Totally irrelevant, they satisfied the obligation to randomize the list, end of story.

      There's lots of problems where there's no licensing board to pass, but for which the solution is important. Automobile control systems, for example. The junior hack to threw this fecal matter out there might get promoted to developing something where it matters but nobody looks. The manager will care that the thing is finished on time and under budget and satisfies the obligations, but that won't be the end of story.

    22. Re:He's just bitching by John+Hasler · · Score: 4, Funny

      > ...the manager ignored it...

      Or he decided that it was so important that he had to do it himself.

      --
      Warning: this article may contain humor, sarcasm, parody, and perhaps even irony. Read at your own risk.
    23. Re:He's just bitching by Anonymous Coward · · Score: 0

      So, your point is that it was a stupid task and therefore should be performed by stupid people? Or that the implementation sort of works some of the time and therefore it's good enough for deployment?
      If that's Microsoft policy, I can see why Google and Apple are kicking its ass.

      Shuffling a list is a menial task that students practice in introductory classes, and there is no excuse for a software company to get it wrong. What you describe as "geek pedantry" is described in wikipedia with 10 lines of code and published in basic computer science text books.

    24. Re:He's just bitching by Teun · · Score: 1
      During one of their many GUI studies MS discovered that humans tend to prefer a certain place when asked to pick from a list.

      That knowledge has now been implemented and apparently in a line of five the last one was favourite number.

      --
      "The likes of Facebook and WhatsApp are free to those whose privacy is of zero value."
    25. Re:He's just bitching by maxwell+demon · · Score: 1

      It was clearly stated in TFA that in this case, it's likely not Microsoft evilness, but just a bad programmer.
      And yes, this shouldn't have happened in Apache either.

      --
      The Tao of math: The numbers you can count are not the real numbers.
    26. Re:He's just bitching by maxume · · Score: 1

      I doubt the problem is from faulty analysis, I'm pretty sure that it is from lack of analysis.

      --
      Nerd rage is the funniest rage.
    27. Re:He's just bitching by pla · · Score: 1

      There's lots of problems where there's no licensing board to pass, but for which the solution is important.

      Agreed. This doesn't fall into that category, however.

      Then again, call me crazy, but I have no problem with having MSIE as the default, as long as you can replace it as the default and (if so desired) remove it fully from your system. Even if I never use it again, if nothing else it means that the second I finish an installation, I can grab updates manually.

      Now, if you want to discuss Windows Media Player, I'll fall more on your side of the issue. I loathe that bloated piece of spyware that breaks all my associations every time I try to play some new file extension that I haven't yet bound to VLC. :)

    28. Re:He's just bitching by IAmGarethAdams · · Score: 1

      To be fair, this is totally random but not by any means evenly distributed.

    29. Re:He's just bitching by Bigjeff5 · · Score: 1

      The only significant position is first. It is well known that users will pick the first choice more often than not unless they have a specific preference for another choice.

      Because of the way most people learn to read (top down), the choice on top is always the first choice. The same is true for left-right, the choice on the left is always the first choice.

      In either case, except when the individual already has a preference, the last choice is always the least often picked. This is why more expensive name brand goods always go at about eye-level in supermarkets - because people often don't look any further than the first choice they see.

      As long as IE is not given an advantage (and they most definitely are not using this function) and are not promoting one browser over another (again, there isn't any sane way you can make that argument - the others are all competitors) then they meet the terms of their anti-trust judgement. There is your definition of "random enough for this", and that quick bit of code certainly achieves it for all of a buck or two in programmer costs.

      --
      Security is mostly a superstition... Avoiding danger is no safer in the long run than outright exposure. - Helen Keller
    30. Re:He's just bitching by Bigjeff5 · · Score: 1

      "the task in question"

      Not give Internet Explorer advantage over competing browsers, as specifically defined in their anti-trust judgements.

      "sufficient"

      Any method that fulfills their legal obligation.

      This function (repeated twice) accomplishes the goal set by the anti-trust judgement, and fulfills their legal obligation:

      aBrowserOrderTop5.sort(RandomSort);

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

      It is roughly 60% random, with IE in the least desirable position about 50% of the time. If it ever came up in court again, Microsoft actually punished themselves extra by using this function, thereby making another lawsuit on this particular matter impossible to win against them.

      It's an extremely easy function and has the added benefit of covering their asses. They are no doubt counting on how ingrained IE is to PC users in order to keep from losing browser share, because that position in the list is definitely not the most desirable.

      --
      Security is mostly a superstition... Avoiding danger is no safer in the long run than outright exposure. - Helen Keller
    31. Re:He's just bitching by Bigjeff5 · · Score: 0, Troll

      Actually they made the very intelligent decision to not waste precious resources on a simple problem with a simple solution that any freshman college student could manage in five minutes.

      Seriously, the only criteria for this browser choice is that Microsoft does not pick the order ahead of time. It needs to be "random" in that the order needs to be chosen at start up, not that it needs to be 99% random.

      The function used is extremely simple, is about 60% random, and consistently puts IE in the last position 50% of the time. Not even a European court is going to come back and say they were giving themselves an unfair advantage, and that's the whole purpose of the function. In court it would be viewed as going "above and beyond" what was necessary to ensure that their browser did not have the advantage.

      What dumbass would waste hours of a programmer's time to solve a problem that can be sufficiently solved in five minutes? Not only is this solution "good enough", from an anti-trust standpoint it is probably far better than a truly random function.

      Seriously, what the hell kind of world do you live on? Wait, wait, let me guess - you're some low-level wanna-be programmer, with absolutely zero management experience, and you think you could run your company better than those who sign your paychecks, am I right? I'll bet you bitch every day around your lunch table to your co-workers about how poorly your company is run, too.

      --
      Security is mostly a superstition... Avoiding danger is no safer in the long run than outright exposure. - Helen Keller
    32. Re:He's just bitching by Bigjeff5 · · Score: 1

      I'm sorry, but the last position is not a premium position, people don't function that way (at least not those who read and write a latin based language). At best it is slightly better than the middle positions, and far worse than the first position (top or left). They would be at a better advantage to give themselves a full 20% chance of getting the front position.

      We always move left to right, top to bottom when looking at choices on a screen for the first time. The first viewed is the one most often picked, followed by the second, third etc.. This is why in search engine rankings the top choice is the most desirable, and the rest are picked far less often. Same thing with brand names in market places, eye-level is the most desirable spot, becoming less so as you move away. The end of the aisles as you walk in are the most premium spots in the store, the opposite ends being far, far less desirable.

      That said, you WILL see a lot of people choosing IE even though it is the last choice. That is because IE has a lot of mind share - it is the most used browser in the world. I wouldn't say it is the best browser, but I wouldn't call it worse than any of the big names either, currently it is mostly a preference issue. If you're used to IE there isn't much reason to switch. Brand new computer users, though, will be using IE less often.

      --
      Security is mostly a superstition... Avoiding danger is no safer in the long run than outright exposure. - Helen Keller
    33. Re:He's just bitching by omfgnosis · · Score: 2, Insightful

      with IE in the least desirable position about 50% of the time.

      It is in the second-most (or most, depending on circumstances) desirable position, because users pay a disproportionate amount of attention to visible ends of a list, particularly a horizontal list. The least desirable position is any middle position on the second screen. This is a consequence of the simplicity of a horizontal list, and user attention shifts accordingly as content grows in height (reading across, down, across, down).

      Microsoft actually punished themselves extra by using this function, thereby making another lawsuit on this particular matter impossible to win against them.

      Doubtful. The mere fact that the order places certain items in certain positions a disproportionate amount of the time would raise considerable doubt that Microsoft acted in good faith. This would be sufficient reason to introduce user test data which would demonstrate that the last position is not the least desirable.

    34. Re:He's just bitching by Rockoon · · Score: 1

      Or they are complying exactly with what was agreed upon.

      Consider the two phrases:

      Present the list of browsers ordered randomly.

      Present the list of browsers sorted randomly.

      Now, most people probably dont see much of a distinction.. but a software engineer who lives and dies on his skill to meet contractual specifications.. yeah.. the two specifications are distinctly different.

      --
      "His name was James Damore."
    35. Re:He's just bitching by CAIMLAS · · Score: 1, Insightful

      Exactly.

      From these results, we can assume one of two things:

      1) Incompetence
      2) Malice

      There may be an off chance of both incompetence and malice given Microsoft's history, but consider that this action was performed solely to meet legal requirements set forth by the EU to inhibit Microsoft's monopolistic behaviors.

      Regardless of which it was, the end result will (likely) be one of two things: the EU will say "not good enough" and another year+ long trial will go on before any actual change gets made, or the EU will let it slide and Microsoft will reap the benefit of whatever they intended with this algorithm.

      To my eyes, it looks like Microsoft is giving preference to 1st place proportionately to the browser current market name recognition - to the exception of their own browser. I don't know if this is intentional.

      However, also consider how dialog boxes typically work, and how people have been conditioned (on Windows and pretty much everywhere else) to immediately look to the left hand side for their "get past this irritating prompt" button. It's a technique used to install all sorts of insidious malware, so evidently it's a technique that works. By having IE hold closest position to that 'visual queue' area, they are giving it preference. Also consider the impact that having the IE logo branding (or any logo, for that matter) on your desktop for a decade will have.

      I would not be surprised to see an article on statistics resulting from this browser selector showing up in a couple months, showing the profound popularity of IE. I'd wager at least 50%.

      --
      ~/ssh slashdot.org ssh: connect to host slashdot.org port 22: too many beers
    36. Re:He's just bitching by noidentity · · Score: 5, Interesting

      You know, your post just made me realize that Microsoft has made a good entry for perhaps next year's Underhanded C Contest: write some innocent-looking code that is supposed to randomize a selection, but fails to do so fairly and favors certain selections over others.

    37. Re:He's just bitching by FlyingBishop · · Score: 1

      There's no guarantee that it's totally random, as that would require each of the 5 numbers be totally random (and likely they are not seeded individually, so they're all the result of the same input to a pseudo-random number generator.)

    38. Re:He's just bitching by Lakitu · · Score: 1

      I'm sure that's why the X that closes Windows' windows is on the far right side, because it is "slightly better"

    39. Re:He's just bitching by Anonymous Coward · · Score: 0

      Who the fuck IMPLEMENTS a randomizing algorithm any more, outside of serious encryption? They'll use the bog-standard rand functions in C++ or C# or whatever.
      This is such a non-story it is laughable that anybody thought to spend more than thirty seconds of thei......

    40. Re:He's just bitching by mestar · · Score: 1

      I think there is 50% chance that you are not a moron, and 100% chance that you are.

    41. Re:He's just bitching by mestar · · Score: 0

      Faster? Are you insane?

      Simpler? It's fcking 3 lines, you can get more simple than that.

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

      If you think you can make this in less code, please do and show us the code.

      This is some trivial stuff that users will probably run ONCE and then never again. Who cares if it is not uniformly distributed.

    42. Re:He's just bitching by mestar · · Score: 1

      I'm sorry, but the last position is not a premium position,

      It could be a spot that is better than the average, but it could also be worse. In this case we simply don't know.

      To know this stuff you have to test it on real people, then measure. This could be a lot of work because most people would select a browser they wanted or whatever, so you would have some problems how to extract the effect of position in this list over other factors.

      My guess is that people that have no clue would simply click the first one.

    43. Re:He's just bitching by mestar · · Score: 1

      As somebody said earlier, the result is totally random, just not with equal probabilities for all browsers.

    44. Re:He's just bitching by mestar · · Score: 1

      But their genius is in how they have hidden this in a simple 3 line implementation!

    45. Re:He's just bitching by Anonymous Coward · · Score: 0

      who gives a shit? MSFT did what those socialist EU people wanted. Anyone in the States needs to be concerned about litigation/action such as this. Look at how the EU beats up on US Corps. Oh I know, they nail European also, but not like foriegn 'competition'. And than out own government jumps into the fray agaisnt corps the EU goes after. Double Socialist jeapordy. All of you MSFT haters really need to look at who the enemy really is. What will you people say when Google or Apple are the next on the hit-list?

    46. Re:He's just bitching by jbengt · · Score: 1

      To be fair, an even distribution was in the requirements.

    47. Re:He's just bitching by Blakey+Rat · · Score: 1

      The developers were forced into making this retarded browser ballot. Of course they're going to do the bare minimum level of effort. It's incredible how ignorant Slashdotters are of human nature.

    48. Re:He's just bitching by The+End+Of+Days · · Score: 1

      Of course, the fact that a proper shuffle can be implemented with the same effort as this nasty hack works against your point, but I can reformulate your point without that error: management often chooses to do things in the most failure prone way possible because they don't understand what they're managing and so make all decisions with naive assumptions instead. Any techie knows that.

    49. Re:He's just bitching by Anonymous Coward · · Score: 0

      That code will be run many millions of times and the order in which the browsers are presented influences the market share of those browsers, so the distribution matters. Microsoft's browser ends up in one of the two edge spots much more often than it would with a uniform shuffle. Whether that favors IE is debatable, but the observation that Microsoft calls the shuffle function twice suggests that they cared enough about the result to test the randomness, so this bug might be deliberate.

      Less code is not the same as simpler code. The core idea behind that code is a hack which apparently is sufficiently non-trivial to have confused a professional programmer into thinking it would do the job (if you believe it is an honest mistake).

      If you only need the sequence once, here's a simple way to get the elements in a random order with a uniform distribution:

      while(array.length>0){
          alert(array.splice(Math.floor(Math.random()*array.length),1)[0]);
      }

      Alert is used in place of a function which does something with each element.

    50. Re:He's just bitching by Anonymous Coward · · Score: 0

      Too bad you can't actually remove IE.

    51. Re:He's just bitching by Anonymous Coward · · Score: 0

      (Correction: I read in another comment that they shuffle twice, but they actually don't. They shuffle a list of the top five browsers and a list of other browsers separately.)

      Drop-in replacement for the Microsoft code follows.

      Replace this

              aBrowserOrderTop5.sort(RandomSort);
              aBrowserOrderRest.sort(RandomSort);

      by this

              shuffle(aBrowserOrderTop5);
              shuffle(aBrowserOrderRest);

      and replace this

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

      by this

      function shuffle(array){
          for (var n=array.length; n>0; ){
              var j=Math.floor(Math.random()*n);
              var t=array[--n];
              array[n]=array[j];
              array[j]=t;
          }
      }

    52. Re:He's just bitching by Toonol · · Score: 1

      Waste resources? This would be a quick, inexpensive routine done right OR wrong. This isn't something you need to be smart, well-educated, and highly-paid to get right. Halfway-intelligent fresh-faced Kids writing games in Gamemaker shouldn't make this mistake. It wasn't an uneducated programmer; it was a dumb programmer. There's ways to get a real random distribution, and they're SIMPLER and EASIER to write.

      It's not a huge deal, and not that critical of a mistake... but I'm looking at the code, and geez. Who writes like this? This looks like code from somebody that's studied their textbook enough to get through some sort of certification, but who doesn't really understand programming at all.

    53. Re:He's just bitching by bmcage · · Score: 1
      I suppose this is an attempt to have a 'funny' post? Or are you serious?

      In my book random means that I cannot guess an order that does not have more probability to occur than another order. As the probabilities are not equal here (eg, little chance of google chrome in position 4 or 5), this is not satisfied.

      I'll assume here that the seed is the cpu time, and the seed is set at the start of the computation.

      The idea is that the comparison is random, but this randomness compared with a known implementation of the comparison of an array, destroys the randomness, leading to some form of predictability.

    54. Re:He's just bitching by mestar · · Score: 1

      Well, your book is wrong. What you are describing is "random with uniform distribution", which is different than random in general.

      For example if you throw two dice, the sum is random, yet not uniform. 7 occurs with 1/6 probability, and 2 or 16 with 1/36 probability. Not all possible events have the same probability, yet it is completely random.

      Same as the result of that sort.

    55. Re:He's just bitching by bmcage · · Score: 1
      What you say is somewhat correct, but not what the programmer of the screen aims at. There is no specific distribution he tries to sample randomly. The aim is exactly to have it uniform. So this is not the same. If you throw two dice, the order of the numbers is random, so no order can be predicted with higher likelihood.

      The sum on the other hand is a derived variable, and shows a distribution.

      The article is about the order in which the browsers occur, and that is not random in the sense you throw a dice, rerolling to remove duplicates.

    56. Re:He's just bitching by Jedi+Alec · · Score: 1

      So they didn't use a shuffle that would pass muster for a licensed video poker system

      Now that you mention it...why didn't they just use the shuffle code from bloody solitaire?

      --

      People replying to my sig annoy me. That's why I change it all the time.
    57. Re:He's just bitching by Short+Circuit · · Score: 1

      No, no, no!

      30 GOTO 10 ' FOR GREAT RANDOMNESS!!!1!!

      (and apparently Slashdot thinks that pre-mixed-case architecture code is like yelling. i'm inclined to agree, but i've added this bit of completely-lowe-case code to the end to be a little less lame.)

      (yes, that's right. in order to be less lame, i need to avoid using caps where occasionally appropriate. whatsnxt? avd xcssv vwls?)

  18. I'm sure it's deliberate by david_craig · · Score: 0, Flamebait

    "But I do not believe there is some nefarious intent to this bug"

    The article states that IE is more likely than any other browser to appear at the bottom of the list. To me, this is one of two optimal positions (top or bottom being easiest to pick out).

    Microsoft is so well known for dirty tricks I'm sure that this is not an accident

    1. Re:I'm sure it's deliberate by Anonymous Coward · · Score: 0

      "But I do not believe there is some nefarious intent to this bug"

      The article states that IE is more likely than any other browser to appear at the bottom of the list. To me, this is one of two optimal positions (top or bottom being easiest to pick out).

      Microsoft is so well known for dirty tricks I'm sure that this is not an accident

      I've been involved in a lot of real life testing of web user interfaces, placements of buttons/options, which get the most clicks, etc. Some quite close to this. And the numbers are overwhelming for the first choice in a line-up like this crushing the others in the distribution of choice. And according to these numbers, Chrome is twice as often in the first position as IE. This is most definitely not the result of some nefarious plan, unless that plan is to buy Google afterwards,

  19. do not fix! by orta · · Score: 1

    looking at the outcome IE comes off the worst with the current algorithm, please keep it that way. Thanks from all the Web Developers.

    --
    my band is more brutal techno punk than yours
    1. Re:do not fix! by jonbryce · · Score: 3, Interesting

      I don't think it comes off worst at all. People usually look towards the right of the screen for the "go away and stop bugging me" button, and that's where Internet Explorer is 50% of the time.

      Remember that the yellow exclamation mark in the system tray telling people they need to reboot is an annoyance when they just want to get on with their work. Then when the computer finally does reboot and they really really want to start doing whatever it was they turned on the computer to do, they get this annoying thing about web browsers.

    2. Re:do not fix! by Anonymous Coward · · Score: 1, Insightful

      looking at the outcome IE comes off the worst with the current algorithm, please keep it that way. Thanks from all the Web Developers.

      Exactly. And the Apple people here managing to interpret this as a plot against Safari are just amazing. MS would represent IE the worst, and Chrome and Firefox the best, just to get Safari. Yeah, right. Talk about delusions of grandeur.

    3. Re:do not fix! by Anonymous Coward · · Score: 0

      I don't think it comes off worst at all. People usually look towards the right of the screen for the "go away and stop bugging me" button, and that's where Internet Explorer is 50% of the time.

      Remember that the yellow exclamation mark in the system tray telling people they need to reboot is an annoyance when they just want to get on with their work. Then when the computer finally does reboot and they really really want to start doing whatever it was they turned on the computer to do, they get this annoying thing about web browsers.

      If you'd been involved in high volume user interface testing (sorry for assuming you haven't, but your theory goes against most such results), you'd almost always see the first choice being overwhelmingly overrepresented in a choice line-up like this. So the winner here looks to be Chrome. I'm willing to bet a lot of beers on MS not doing that on purpose.

    4. Re:do not fix! by omfgnosis · · Score: 1

      No, Safari is in the worst spot most of the time. The end of a list is either the best or second-best (depending on circumstances and presentation) position if the entire list is present, visible and accessible. All middle positions are at a distinct disadvantage, and the second to last position at the greatest disadvantage.

    5. Re:do not fix! by omfgnosis · · Score: 1

      And lest I be biased, I'll offer my browser preferences for full disclosure.

      I use Safari as my primary browser, but only as I wait for Chrome to meet my needs (note the first position is biased toward Chrome). I prefer WebKit as a renderer; Chrome is a better browser than Safari overall, but doesn't (yet?) support certain aspects of my workflow.

    6. Re:do not fix! by Anonymous Coward · · Score: 0

      BTW, the taskbar is not the "system tray." To the best of my knowledge there is no "system tray."

      For ancient history, please refer to http://blogs.msdn.com/oldnewthing/archive/2003/09/10/54831.aspx

  20. Re:What? Why not? by Lehk228 · · Score: 1

    i'm trying to figure out why they went to the trouble of screwing things up as bad as they did, a trivial decrementing for loop pulling randomInt(1,i) and placing it in slot 5-i would be the obvious off the top of the head solution, and it would work.

    --
    Snowden and Manning are heroes.
  21. I have no problem with this at all by Zocalo · · Score: 1, Informative
    Frankly, I have no problem with this result. Quite the opposite in fact, since I think you can probably group the users into three sets, only one of which really matters in connection with the Browser Selection Screen:
    1. Those that equate "Internet" with a blue "e" and as such will pick IE regardless of its position
    2. Those that prefer another browser to IE and will pick another option regardless of positioning
    3. Those that have no clue about browsers and pick essentially at random, or belong to one of the above groups and click in error.

    The only people where the selection and any possible bias inherent in the implementation of the random() function are the last group, which is also quite possibly the smallest of the three sets. In an ideal world, you are going to get a bellcurve with the optimum position being in the middle and the least favourable at the sides, so if Microsoft wants to implement random() so that IE is more likely to end up in the position that is joint least likely to be picked of the big five browsers, that's fine by me.

    It's also apparently fine for Google's Chrome as well, so if you are anywhere near Ballmer's office in the next few days then I'd keep an eye out for any flying chairs, just in case...

    --
    UNIX? They're not even circumcised! Savages!
    1. Re:I have no problem with this at all by westlake · · Score: 1

      3 Those that have no clue about browsers and pick essentially at random, or belong to one of the above groups and click in error.

      It won't be a random choice.

      They will choose the browser associated with their operating system:

      Microsoft Windows = Microsoft IE 8 for Windows.

      The only people where the selection and any possible bias inherent in the implementation of the random() function are the last group, which is also quite possibly the smallest of the three sets.

      It is more likely the largest of the three sets.

      These aren't geeks shopping for tech, these are ordinary people looking for a familiar and trusted brand name.

      The ballot is a bureaucratic perversity that will play to Microsoft's advantage.

    2. Re:I have no problem with this at all by jonbryce · · Score: 1

      Those who prefer another browser to IE will have already installed one, and they won't see this screen.

    3. Re:I have no problem with this at all by Zocalo · · Score: 1

      If they are not picking IE at random, then they probably belong in my first group then, albeit with a change of descriptive text as whether the association is "Blue e = Internet" or with the name Microsoft is neither here nor there in context. I don't think that this group is necessarily as large as you might think though, in my experience the kind of person who falls into this set has a considerable overlap with the set of users that only upgrades their OS when they get a new computer.

      Personally, I think this whole concept is a stupid idea that's right up there with some of the other brain dead excuses for legislative rulings that have come out of the EC, and won't change the status quo by meaningful amount. Once you've deducted the users who will pick a non-IE browser anyway and those who will pick IE based on either its icon or the name "Microsoft" regardless of its position on the screen, there are not too many users left. I doubt very much that when the next round of browser usage figures come in that there is going to be a significant shift towards non-IE browsers that could be attributed to the introduction of the Browser Selection Screen.

      --
      UNIX? They're not even circumcised! Savages!
    4. Re:I have no problem with this at all by maxwell+demon · · Score: 1

      The will have it installed before they switched it on the first time? I doubt so.
      They will have it installed before using the Internet the first time? Possible, but unlikely: Where will they get the browser from? Most likely they downloadf it from the net. For this, they'll most likely try to open the browser's download page with IE, which leads them directly to this screen.

      --
      The Tao of math: The numbers you can count are not the real numbers.
    5. Re:I have no problem with this at all by jonbryce · · Score: 1

      When people get a new computer, yes. But existing users who get the browser choice update over the next month or so as they run Windows Update, only people who have Internet Explorer as their default browser see this screen.

      I've only seen it on one of my machines, a Parallels virtual machine which has IE6 as the default browser. My other machines either have Firefox as the default browser, and I got the browser choice update but nothing happened after that, or they don't run Windows.

    6. Re:I have no problem with this at all by maxwell+demon · · Score: 1

      OK, I wasn't aware that this screen is also shown on Windows installations already in use. I thought it only applied to newly installed Windows.

      --
      The Tao of math: The numbers you can count are not the real numbers.
  22. Re:What? Why not? by Anonymous Coward · · Score: 5, Insightful

    No, Math.random is not the problem, the problem is how it is used. They used it as random input to a sorting algorithm without considering how the sorting algorithm works. The assumption that any sorting algorithm with inconsistently random input = random order is wrong. If they had assigned a random value to each element and sorted by that value the result would have been truly random as the value associated with each element would have been consistent.

  23. Interesting that random compare is not random... by SuperKendall · · Score: 1

    What they essentially did was use something like qsort() to sort the list, but in their comparator function, instead of returning which of the two strings comes first, they return some random crap instead.

    That algorithm seems really wrong, for the reason you mentioned - that potentially you get an infinite loop.

    However after further thought, I don't think that result is possible, and I find it more interesting to think about why this does not work as intended. After all, if you are randomly comparing random numbers why is the end result not still random?

    First, why it is not going to ever result in an infinite loop - because pretty much any sorting algorithm is not going to engage in an infinite number of comparisons. Pretty much any technique I can think of is always going to be left with an assumption about a growing number of elements and where they fit into place, so even though the comparison result is totally random the sort will always complete (the results will just always be wrong, if you can call any ordering based on a broken comparator wrong).

    I think that the non-randomness of the result is related, in that that assumption is made as to where a value falls and then the remaining elements fall into line after that result... which might explain how one element like Safari was so out of whack when the others were also out of balance but to a lesser degree, as the initial list is probably always fed in the same order and the algorithm works on one particular element first to start the sort (which might also explain the browser variation, having slightly different sorting algorithms).

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley
  24. Read the results, not good enough by SuperKendall · · Score: 2, Insightful

    Given that each user is only going to see this screen once per computer, I'd say simply using the seconds of the current minute as a random seed should be OK.

    A) That was not the problem.

    B) Consider the result instead of the algorithm is it OK to have your "random" list just about always present any one choice in the bottom two elements? Because that is what happened for Safari.

    If you aren't going to insist on a list that's even close to random then you should not make randomness a requirement.

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley
  25. Seems like the right solution to me by kevinNCSU · · Score: 2, Insightful

    One solutions takes 3 seconds, can be done by an intern, and makes the company no money. The other solution takes a little bit of time, maybe some reading or prior knowledge and still makes the company no money. The results yielded for each solution are acceptable for the situation. Given the cost to profit it seems like Microsoft chose EXACTLY the right solution.

    This is like your community telling you that you must have a fenced in yard for your dog to be off the leash and then setting up a cheap 6-foot standard wooden fence and then the local anti government militia guy laughing at your ignorance because everyone who knows anything about fences knows you choose the solution that's 12 feet high with curved top to prevent climbing and a sunken base of 3 feet to prevent dog-tunneling.

    1. Re:Seems like the right solution to me by SpinyNorman · · Score: 1

      Well, as it happens (if you read TFA) Microsoft's solution ends up being biased against Microsoft rather than for them. It hard to say which is worse, though; in one case you work against your own market share, in the other you end up wasting time and money as the EU hauls you back in court for unfair practices.

      It seems the least cost option for Microsoft would have been to have gotten this right first time (as is always the case with software).

    2. Re:Seems like the right solution to me by Anonymous Coward · · Score: 0

      If they're instructed by a governing body to implement random selection, it might be in their best business interest to do it well even if they make no money either way.

    3. Re:Seems like the right solution to me by kevinNCSU · · Score: 1

      You're right, after reading TFA this was a poor choice. The summary misled me into thinking that they didn't think you could just throw math.random() at a problem like this which you absolutely can. You just can't throw it at is in such a retarded way. What should have been summarized is that you can't violate the rules of sorting by using math.random() inside the comparator itself and still expect to get random results. Microsoft got lucky here that they're the ones that get put in the fifth spot otherwise your right, it could have ended up costing them even more money.

    4. Re:Seems like the right solution to me by YourExperiment · · Score: 1

      You're saying that it makes no difference to Microsoft whether IE appears last on the list 50% of the time (what is actually happening) as opposed to 20% of the time (what should be happening)?

    5. Re:Seems like the right solution to me by pipedwho · · Score: 1

      No, Microsoft's solution has a 50% probability of putting them in the rightmost position on the screen. It has been shown that people are biased to selecting the first and last elements of a list with much greater probability than the central elements.

      So, in this case, Microsoft's error was definitely in their favour over the other four browsers.

    6. Re:Seems like the right solution to me by noidentity · · Score: 1

      I'm not as bothered by the lack of randomness as the violation of the constraints for a comparison function, as covered in the blog entry. It's like the newbies who want to write a comparison for a structure with two integer members, and write the is_less as (x.i y.i) || (x.j y.j) (or some such simplistic incorrect version).

    7. Re:Seems like the right solution to me by noidentity · · Score: 1

      And me who forgets to encode my entities in HTML. Let's try again.

      I'm not as bothered by the lack of randomness as the violation of the constraints for a comparison function, as covered in the blog entry. It's like the newbies who want to write a comparison for a structure with two integer members, and write the is_less as (x.i < y.i) || (x.j < y.j) (or some such simplistic incorrect version).

    8. Re:Seems like the right solution to me by pipedwho · · Score: 1

      Not necessarily. If the court deems they did this through negligence or intent, they could risk further fines. And those fines could cost considerably more than using the 5 second solution instead of the 3 second solution.

      I can see it now:

      Divisional manager: "Hey boss, we saved $5 dollars of coder time by using a junior guy that didn't know his arse from a uniform distribution shuffle algorithm."

      Boss: "We know. Because of that mistake, the courts just imposed another $10000 dollars per day penalty over and above our current fine."

    9. Re:Seems like the right solution to me by Anonymous Coward · · Score: 0

      It's not like you need a PhD in statistics to shuffle an array, you could just google it and copy paste the 3 lines of code that appear in most of the first results. It takes more effort to come up with the plainly wrong algorithm they implemented than to find out the right one.

      This is like saying that you need to sort an array, an instead of using a well known algorithm, you make up your own, which is inefficient and wrong 50% of the time, but hey, it's a non-critical task so who is going to notice anyway?

      I don't care what the cost/benefit seems to you, it's not cheaper to write bad code, microsoft can afford to hire people with a minimum of quality standards.

    10. Re:Seems like the right solution to me by Anonymous Coward · · Score: 0

      Bad analogy.

      And the premise is exactly the sort of micro-cost-management that is ailing most of the economic sectors in the US today.

      Putting up a stronger-than-necessary fence takes more materials besides needing to more work. And if in the future one no longer has the dog and now wants to get rid of the fence, there's more work to tear it down, incurring yet more costs.

      Whereas the algorithm issue is only a matter of "work smarter, not harder".

      The bad algorithm takes no less time to code than the good algorithm, and quite possibly longer if done by an inexperienced programmer who is flailing around instead of knowing when to ask a question of their colleagues.

      And even if the programmer didn't know better at first, there's plenty of opportunities at lunch or around the water-cooler for smalltalk along the lines of, "Hey I had this problem come up today ... how would you have solved it?"

      The net result is it costs the programmer and company hardly any more time and money, but in the latter case, the programmer learns something. They become a little bit better at what they do, and by extension, are worth more to the company.

    11. Re:Seems like the right solution to me by Graff · · Score: 1

      One solutions takes 3 seconds, can be done by an intern, and makes the company no money. The other solution takes a little bit of time, maybe some reading or prior knowledge and still makes the company no money. The results yielded for each solution are acceptable for the situation. Given the cost to profit it seems like Microsoft chose EXACTLY the right solution.

      I dunno, a quick Google for "javascript shuffle array" brings up this simple function as the first result:

      //+ Jonas Raoni Soares Silva
      //@ http://jsfromhell.com/array/shuffle [v1.0]
       
      shuffle = function(o){ //v1.0
          for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
          return o;
      };

      It didn't take much time at all to do the search, probably just as much time as it took to come up with the wrong function that Microsoft used.

    12. Re:Seems like the right solution to me by asaz989 · · Score: 1

      What ever happened to a programmer's pride in the craft? Or (on a more self-interested level) checking what your interns do to make sure they don't learn bad coding practices?

    13. Re:Seems like the right solution to me by kevinNCSU · · Score: 1

      To be honest I misunderstood the issue at hand to be whether math.random() produced random enough results rather then it being a completely nonsensical use of math.random() in a sort comparator

      As for checking what interns do I wouldn't expect a task this menial to require checking. I guess that's something I take for granted working at a small company that can afford devoting time to quality control during the hiring process.

    14. Re:Seems like the right solution to me by KingMotley · · Score: 1

      And if you google "javascript random sort" like most programmers who don't use "shuffles" every day (or ever), the top hit is exactly what Microsoft implemented.

    15. Re:Seems like the right solution to me by Anonymous Coward · · Score: 0

      You forgot the cost of failing compliance with EU directives.

    16. Re:Seems like the right solution to me by Anonymous Coward · · Score: 0

      Are you an expert on interface design and EU law? Over and over I see you asserting that the last choice in the list is a place of primacy, and Microsoft could be liable for this. Do you even know if the decision specified a uniform distribution of random results? Do you even know the difference between that and the mess you keep spewing here? What do you know, exactly, besides "Microsoft is evil?"

    17. Re:Seems like the right solution to me by Graff · · Score: 1

      And if you google "javascript random sort" like most programmers who don't use "shuffles" every day (or ever), the top hit is exactly what Microsoft implemented.

      A couple of results down yields this link that talks about how it is wrong in several ways to use sort verses a shuffle.

      This comes down to a programmer just not doing enough research before implementing a solution. Programmers who use the first Google link without digging deeper can get themselves into some serious trouble. A few minutes spent up-front doing a little research can save you hours of headaches later.

    18. Re:Seems like the right solution to me by KingMotley · · Score: 1

      And you do more research, and read the entire page that you linked, you will see they even say either approach works in all modern browsers, including the method Microsoft used:

      "My technique was to take a small array [1,2,3,4] and create all (4! = 24) permutations of it. Then I would apply the shuffling function to the array a large number of times and count how many times each permutation is generated. A good shuffling algoritm would distribute the results quite evenly over all the permutations, while a bad one would not create that uniform result.

      Using the code below I tested in Firefox, Opera, Chrome, IE6/7/8.

      Surprisingly for me, the random sort and the real shuffle both created equally uniform distributions. So it seems that (as many have suggested) the main browsers are using merge sort. This of course doesn't mean, that there can't be a browser out there, that does differently, but I would say it means, that this random-sort-method is reliable enough to use in practice."

    19. Re:Seems like the right solution to me by Graff · · Score: 1

      And you do more research, and read the entire page that you linked, you will see they even say either approach works in all modern browsers, including the method Microsoft used

      A number of people in that thread call the sorting algorithm into question, none say anything bad about the shuffling algorithm. Overall a smart developer would take this as a cue to do a little more digging into each algorithm and would ultimately choose the Fisher-Yates shuffle over the sorting hack. Both algorithms are about as simple to implement but the shuffle algorithm is faster and more reliable. It's a no-brainer which should be used. In fact, the same guy you quoted also had this to say:

      But on the performance side the shuffle function given by Cristoph was a clear winner. Even for small four-element arrays the real shuffle performed about twice as fast as random-sort!

  26. You can't artificially put down competition by SuperKendall · · Score: 5, Insightful

    Here's the problem - consider the results again. Safari will almost always (almost 50% of the time) be put in the bottom two elements. In fact depending on the algorithm used it's 40-50% chance of being put in one exact slot (either choice four or five).

    When the whole point of the list is promote browser competition, it makes no sense to accept a list which is that skewed for ANY browser result from the list. You need to have it properly shuffled so that no one browser has a statistical advantage or disadvantage - if you are going to claim it doesn't matter then why not let Microsoft set an arbitrary fixed order for the list?

    That is not what the legal injunction against them says they can do, therefore the randomness of the results DO matter. Just as in most things in life, correctness of results is actually important.

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley
    1. Re:You can't artificially put down competition by pushing-robot · · Score: 4, Funny

      Safari will almost always (almost 50% of the time) be put in the bottom two elements [out of five].

      And how well did you do in statistics class?

      --
      How can I believe you when you tell me what I don't want to hear?
    2. Re:You can't artificially put down competition by CajunArson · · Score: 1

      Wow... the bottom 2 elements out of a possible 5 ALMOST 50% of the time.. talk about a massive skew by those evil MS guys....

      BTW... did you ever see the Dilbert cartoon with the PHB complaining that a full 40% of employee sick days were taken on Mondays and Fridays? You weren't possibly the same PHB were you?

      --
      AntiFA: An abbreviation for Anti First Amendment.
    3. Re:You can't artificially put down competition by Aladrin · · Score: 2, Insightful

      I don't know how you managed to get 'insightful' mods for this.

      For a completely random algorithm: Out of 5 slots, EACH item has a 20% chance to be put in any single slot. For any 2 slots, that's 40%.

      Let's look at your statement again: "Safari will almost always (almost 50% of the time) be put in the bottom two elements. In fact depending on the algorithm used it's 40-50% chance of being put in one exact slot (either choice four or five)."

      Wow. So you're saying that it's working perfectly.

      --
      "If you make people think they're thinking, they'll love you; But if you really make them think, they'll hate you." - DM
    4. Re:You can't artificially put down competition by jim_v2000 · · Score: 1

      "That is not what the legal injunction against them says they can do"

      How do you know?

      --
      Don't take life so seriously. No one makes it out alive.
    5. Re:You can't artificially put down competition by SuperKendall · · Score: 1, Insightful

      Obviously I didn't explain what was going on very well, I (stupidly) assumed people would read the actual article and the data there. But hey, this is Slashdot so I guess I better fill you in.

      It's not two slots. It's one slot (look at the results). The "bottom two" comes from the fact that in each browser test, a SINGLE SLOT was used either 40% or 50% of the time (depends on the browser). The exact NUMBER of the lost depended on which browser was being used. Thus we are talking about 40-50% vs 20% (which would be random).

      Furthermore the 50% is still out of variance by a decently large factor, even if we were talking about two whole slots instead of one.

      So, "wow" yourself. Look at the data next time before you leap to conclusions, or state that an utterly broken algorithm is "working perfectly".

      --
      "There is more worth loving than we have strength to love." - Brian Jay Stanley
    6. Re:You can't artificially put down competition by Anonymous Coward · · Score: 0

      Bull shit-It is because of Safari that this happened. When you cannot compete-litigate.Safari deserves nothing in terms of choice. I personally use FireFox more than IE, but I will never use Safari not Chrome due to their practices. So there!!!! Personally, I feel that if MS has to open up browsers, then so should Linux Distros and Mac. Where is the heartburn about Mac or Ubuntu with all of the stuff they load onto their systems and then prevent one from loading outside stuff?? Fairness of competition? Sure if skewed against MSFT and in favor of anyone else. Hateful, spiteful little people who need to get lives. In fact, I think that is what I will do-go on a run with a friend before dark

    7. Re:You can't artificially put down competition by feepness · · Score: 1

      And how well did you do in statistics class?

      Sadly, 90% of his class was below average.

    8. Re:You can't artificially put down competition by Otis_INF · · Score: 1

      So, considering it's not entirely random, which browser is likely to land in the spot where most users will look first (in the middle) ?

      As 5 choices are offered, in which order they are presented is not really that interesting. What's interesting is how users will pick their choice: if the vast majority will pick the 3rd one (middle) because they don't have time / want to read all the choices' options, it's more interesting which browser that will be.

      Unfortunately, unless we know what kind of user patterns are likely, we can't really judge the numbers. For example if it was the most less likely that a user would pick the most right one from a set of 5 characters on screen, MS would put its biggest competitor there. And they don't see FF as their competitor, but google.

      --
      Never underestimate the relief of true separation of Religion and State.
  27. Re:What? Why not? by Animaether · · Score: 1

    I thought it was originally going to be that they forgot to seed the random number generator or something.

    Out of curiosity - why would they need to seed the random number generator?

    Wouldn't -not- seeding it be better? That way MS don't have to include some seed number in their script and have everybody thinking they're manipulating the results by using seed numbers that they know would generate a certain ordering in various versions of IE.

    I actually found this bit...

    Repeating the same test on Firefox is also non-random, but in a different way:

    ...rather interesting. How are two browsers using the same script resulting in different ways of being non-random; presuming that, in itself, was not by chance?

    Although I can't verify this, as the test page provided... http://www.robweir.com/blog/shuffle.html ...won't actually run in IE8 here :D

    That said.. odd method of getting random results out of an array.. I'm sure it's more efficient but KISS would dictate you grab one random result out of the array, delete the one you chose, pick a new one, delete, etc. until the array is down to 1 and you stick that last one at the end. Can't really go wrong with that unless the random number generator itself is hosed, and even non-mathematicians can understand how that one works. It's not like it's a high-performance application.

  28. Bug in the story by tomhudson · · Score: 1

    Microsoft used none of these well-known solutions in their random solution. Instead they fell for the well-known trap. What they did is sort the array, but with a custom-defined comparison function. JavaScript, like many other programming languages, allows a custom comparator function to be specified. In the case of JavaScript, this function takes two indexes into the value array and returns a value which is:

    • < 0 if the value at the first index should be sorted before the value at the second index
    • 0 if the values at the first index and the second index are equal, which is to say you are indifferent as to what order they are sorted
    • < 0 if the value at the first index should be sorted after the value at the second index

    According to the description, it returns either 0 or < 0.

    That's not the way the comparator function works in any implementation I've seen. Hopefully, the test code the author wrote wasn't as random as the documentation.

    1. Re:Bug in the story by maxwell+demon · · Score: 1

      Sure, a simple, obvious typo in the actual testing code would be much more fatal than a simple, obvious typo in the description. That's because compilers are not intelligent and won't (and shouldn't) recognize the obvious typo as such.

      --
      The Tao of math: The numbers you can count are not the real numbers.
  29. Simple solution by Anonymous Coward · · Score: 0

    Excel formula:

    =ROUND(RAND(),1)*10 .
    This works for up to 11 different browsers (yes, 0 is a number).

  30. Re:What? Why not? by maestroX · · Score: 1

    kdawson obviously skimmed the article for a few seconds and attributed the flaw to Math.random and Microsoft.

    Of course, hindsight is always twenty-twenty. We now know a shuffling algorithm should have been used and Microsoft could have evaded prosecution by including a random^H^H^H^H^H^Hshuffled list of browsers for shuffling the list of browsers instead of IE only to run the browser selection process.

  31. Re:What? Why not? by maxwell+demon · · Score: 1

    i'm trying to figure out why they went to the trouble of screwing things up as bad as they did, a trivial decrementing for loop pulling randomInt(1,i) and placing it in slot 5-i would be the obvious off the top of the head solution, and it would work.

    No, it wouldn't work. Here's a possible run of that algorithm:

    Initial:
    a = -----
    Step 1: randomInt(1,5) -> 3
    a = ----3
    Step 2: randomInt(1,4) -> 1
    a = ---13
    Step 3: randomInt(1,3) -> 2
    a = --213
    Step 4: randomInt(1,2) -> 1
    a = -1213
    Step 5: randomInt(1,1) -> 1
    a = 11213

    Doesn't look like a random shuffle. Indeed, it doesn't even look like a shuffle at all.

    Indeed, your algorithm has the following properties:

    • always a[0] == 1
    • the only possible result where all 5 numbers occur (i.e. the only result where the result is a permutation of the numbers from 1 to 5) is a == {1, 2, 3, 4, 5}
    • the only place where 5 could be is a[4]
    --
    The Tao of math: The numbers you can count are not the real numbers.
  32. Re:What? Why not? by Tapewolf · · Score: 2, Informative

    Out of curiosity - why would they need to seed the random number generator?

    Wouldn't -not- seeding it be better?

    I can't speak for Javascript but in most C libraries - at least in the DOS era when I last made this mistake - the library would default to a static seed of its own during program initialisation, probably 0 or something.

    As a result, if you made a program that started, output 15 random numbers and then quit, each time you ran it you would get the same 15 numbers.
    What you're supposed to do to avoid that is seed the RNG at the program start, using the current time since the epoch as the seed. This is what I was referring to, not using a static seed :P

  33. Re:Jesus Fucking Christ by Anonymous Coward · · Score: 0

    This is why people don't take you freetards seriously.

    People don't take us seriously because we think that software should be implemented correctly, and that the programmers employed by the world's most successful software company should know trivial algorithms? Ri-i-i-ight.

  34. Random by Greyfox · · Score: 3, Funny
    I like this one.

    Anywhoo... So what you're telling me is that Microsoft's programmers made a mistake for a production system that 99% of freshmen CS students wouldn't make? In this case, I think you're actually giving too much credit to Freshman CS students...

    --

    I'm trying to teach myself to set people on fire with my mind... Is it hot in here?

    1. Re:Random by Bigjeff5 · · Score: 1

      I don't accept the premise that the function needed to be truly random (in a practical sense, 99% or so). I think the cheap and easy solution using math.random is perfectly fine. It works out to about 60% random, which is adequate for the purpose of ordering a list of browsers. Since spending the time using a solid random function isn't going to make Microsoft any more money, the quickest and easiest solution is the best choice. This function uses very well known functions, and it is all of five lines long. You can't get much cheaper and easier than that.

      That said, regarding the misuse of random functions in code that does need to be truly random (again, 99% is usually good enough), I'd be extremely surprised if 99% of freshmen CS students didn't make this mistake the first time they were asked. A lot of people here on slashdot have done it even though we are talking about how non-random random is when used in this way.

      Then when the prof shows them how abysmally they did, the lesson is learned, and hopefully 99% of sophomore CS students wouldn't make that mistake. The reason everybody remembers it so well is because they screwed it up so badly the first time they tried it.

      --
      Security is mostly a superstition... Avoiding danger is no safer in the long run than outright exposure. - Helen Keller
  35. On the up side: it's a webpage. On the down side: by Animaether · · Score: 1

    On the down side.. it's a webpage.

    To cover the first bit.. it's a webpage - if a potential problem has been found, it can be fixed. I.e. this random selection thing? They can implement a better one.

    Though I do wish they would start by fixing the page's use of javascript to sort the results -after- their display.
    Turn off Javascript.. the order appears to always be: IE, FF, Opera, Chrome, Safari.

    In fact - if you have a slow machine like I do.. leave javascript on, and just refresh the page.. look closely, and you'll find that -that- is the order of display *before* it gets shuffled by the javascript.

    On the down side... if they were to detect the user not using javascript, and would switch server side-shuffled results instead, people would wonder how fair -those- are.. and since they can't peek inside the server, there's no way to tell.

    Which leads to another down side... it's on a server out of our control - it's entirely possible, albeit unlikely, that one out of N hits favors browser X by design.

    note: I don't really care much.. I don't think this should have been pushed through at all. But if they -have- to do it, I'd rather they do it well, just because it would have prevented the flurry of articles on this and other issues (such as the rollout not being instant, but stretched out through April(?) - probably to keep media attention / panicked users calling their tech support to a minimum), even in times to come.

  36. Might be a mistake but not where Rob is pointing by ma_luen · · Score: 1

    Well unless there is something else going on Rob needs to go back to school too. A simple quicksort algorithm with the comparator replaced with a random choice becomes a recursive random partition of the array. A simple inductive argument shows that this will not produce the unbalanced results he found. So the problem is elsewhere (most likely in the RNG seeding or a bias in the pivot selection, if he is running it in a tight loop and the seed is something like, current second, then the same seed may appear several times).

  37. Re:What? Why not? by Animaether · · Score: 1

    I can't speak for Javascript but in most C libraries - at least in the DOS era when I last made this mistake - the library would default to a static seed of its own during program initialisation, probably 0 or something.

    A-ha... crystal clear - thanks for clarifying :)

    Just to check - IE8 certainly seems to do this - whether it does it properly, I wouldn't know, but it's certainly not the same results each time I fire up IE8 with a test page (just printing out 10 random numbers).

    This is what I was referring to, not using a static seed :P

    Certainly not ;) But if MS were to seed the number, they'd still have to get that seed out of somewhere.. though I suppose they could use javascript date/time functions for that.

  38. The only true random function by Jorl17 · · Score: 1

    There's only ONE trully random-compliant function: http://xkcd.com/221/

    I use it everyday. Funny, though, 4 turned out to be my good-luck number since I started using it...

    --
    Have you heard about SoylentNews?
    1. Re:The only true random function by maxwell+demon · · Score: 1

      Sorry, but that function is buggy. I just tested with my totally fair die, and I got a 3, not a 4. So the return value should definitively be 3.

      --
      The Tao of math: The numbers you can count are not the real numbers.
  39. Re:Might be a mistake but not where Rob is pointin by ma_luen · · Score: 1

    And to follow up after re-reading the article he claims that non-termination is possible. But since in quick-sort each recursive call is to a smaller list (we removed the pivot element otherwise the algorithm has real problems) the sort must always terminate.

    Now this might not be a very elegant solution and definitely violates the abstract specifications of a sort routine but the problems pointed out by Rob are not actually the real problems. Way to go slashdot, always making sure articles that slag on Microsoft are factually accurate .

     

  40. Re:What? Why not? by Your.Master · · Score: 1

    I'm almost certain he's suggesting you splice out the array item chosen each time so that the remaining indices are enumerated as 1-X at all times. I'm pretty sure that would work.

    I'm not convinced it is simpler, although I see a couple people on slashdot suggesting it is. Adding a random comparator to an existing sort function is dead simple and obvious (wrong, but simple and obvious), and I'd be surprised if it weren't a lot more than 1% of freshmen that come upon that one, particularly when the top search results actually suggest that broken algorithm, unless these freshmen had never encountered sort functions before.

  41. Real summary: (Skip TFA, /. style) by Mashdar · · Score: 1

    Microsoft used bogus, non-static, comparisons of random numbers to "sort" the list, but they generated new, meaningless random numbers for every comparison. IE must have been the last entry, and had a 50% chance of the sort loop exiting the first time it was encountered (leaving it in the last position). IANAProgrammer and this is an obvious error to me. I thought TFA was going to be about a poorly seeded random number generator.

  42. Is it really about 1-5? by A+Friendly+Troll · · Score: 1

    Isn't the *middle* choice going to be more important than the leftmost one?

    We have a screen-centred dialog here that shows five browsers. One is going to end up smack-middle on the screen - and guess what - Windows centres the mouse pointer when it boots, which is when the screen will appear.

    People often go for middle ground. Then they go to the direction they read... So in my mind, the 3rd choice is going to be the most important, followed by 4 for LTR cultures, and 2 for RTL.

    But I'm talking out of my ass here... Any research into the importance of elements in a short horizontal list?

  43. Re:What? Why not? by rxan · · Score: 1

    As another poster said there is a slight error. A fix would be to use a vector holding the remaining browsers to randomly select as the next item in the shuffle list. Or you could use probability theory to shift the list of randomly generated indices so only remaining indices as selectable in each iteration.

    MS should have kept it simple. There's no need to overcomplicate something so trivial.

  44. Naive Solution? Inexeperienced? Whaaaat? by JimboFBX · · Score: 0, Troll

    Ok in all fairness, bubblesort is arguably the best sorting algorithm because in today's modern computing power it will do the job sufficiently for 99% of your problems and is easy to implement and verify. Its especially efficient when appending an already sorted array to another already sorted array, which some other popular algorithms can't claim.

    And the naive solution to a shuffling an array is similar to bubblesort, traverse through the array and generate a random number up to array size to swap the element with. If current position + number > array size then deduct the array size from the number to get the position to swap with. Maybe I should patent that because it apparently isn't obvious.

    I think I have to agree that this looks like a situation where an author, likely a young one, is trying to nerd off when they dont understand how Microsoft operates. My question is why would you go through this kind of effort in the first place...

    1. Re:Naive Solution? Inexeperienced? Whaaaat? by Mashdar · · Score: 1

      The point is that it is easily explained by a stupid programming move, and not by some conspiracy to list Microsoft's own product last. Oh, and this is Microsoft, so are we really surprised at the possibility of epic algorithmic mistakes?

      And he spent "this kind of effort"
      A) Because he had a few hours to kill.
      B) Because he found it interesting.
      C) Because he wanted to back up his blog story with actual tests.
      D) All of the above.

    2. Re:Naive Solution? Inexeperienced? Whaaaat? by Mashdar · · Score: 1

      PS I see what you are saying about the summary, it seems to imply that bubble sort is bad, but really it was just a poor use of well known methods (which presumably some beginner threw at a problem without thinking).

    3. Re:Naive Solution? Inexeperienced? Whaaaat? by BZ · · Score: 1

      > And the naive solution to a shuffling an array is similar to bubblesort, traverse through
      > the array and generate a random number up to array size to swap the element with.

      While this is not in fact perfectly random (the right way would be to generate a number up to remaining elements, then add the offset), it's a lot more random than what Microsoft did here. Did you read the article?

      Note that the article author is 40 years old. Dunno whether you consider that "young".

    4. Re:Naive Solution? Inexeperienced? Whaaaat? by Anonymous Coward · · Score: 0

      Ok in all fairness, bubblesort is arguably the best sorting algorithm because in today's modern computing power it will do the job sufficiently for 99% of your problems

      Um... no. Just no. We're not talking about bubble sort being two or three times slower than the good algorithms, it can be hundreds, thousands, millions, ..., of times slower, depending on how big your data set is. Unless of course you think that 99% of problems use tiny data sets.

    5. Re:Naive Solution? Inexeperienced? Whaaaat? by Anonymous Coward · · Score: 0

      You are a fucktard who doesn't understand big-O notation if you believe that, and have no business programming anything.

    6. Re:Naive Solution? Inexeperienced? Whaaaat? by mmmmbeer · · Score: 1

      Successful troll is successful.

    7. Re:Naive Solution? Inexeperienced? Whaaaat? by Anonymous Coward · · Score: 0

      Department of Redundancy Department is redundant.

    8. Re:Naive Solution? Inexeperienced? Whaaaat? by Anonymous Coward · · Score: 0

      Note that the article author is 40 years old. Dunno whether you consider that "young".

      Unfortunately, I am old enough that I do.

    9. Re:Naive Solution? Inexeperienced? Whaaaat? by Anonymous Coward · · Score: 0

      Unless of course you think that 99% of problems use tiny data sets.

      Yes.

  45. Eh? by Anonymous Coward · · Score: 0

    Still caring about which browser people are using? Some people just can't let the fuck go.

    It falls right up there with what kind of toilet bowl cleaner I use on my list of things that concern me.

  46. This is why we get outsourced by sohp · · Score: 1

    I'm a senior programmer, over 10 years experience. I don't think I would have EVER imagined a solution to randomizing that would involve a sort comparison function returning a random result. This is because I have an understanding of the implicit (and in some languages, explicitly documented) total ordering contract imposed on the comparator function.

    But you know what? If Microsoft doesn't care for nice things like correctness, why would any big software development company? Excepting cases like Wolfram Research's Mathematica and Autodesk's AutoCAD, of course. And yet they have the balls to call their people software engineers?

    I'm not disagreeing with the conclusion that the quick and cheap way is sufficient and satisfactory from both the business standpoint and for this problem the technical standpoint. I'm simply saying that, as a profession, the field is so compromised with crap like that this that it's no wonder most software sucks. It's easy to see how an experienced and knowledgeable developer can be replaced by a couple of best-low-bid hacks.

    Of course management rarely sees or understands the difference between throwing a hacked up function at an unimportant problem like this one, and doing the same thing when designing the firmware for a car, a risk calculation algorithm for derivative investments, or the math portion of a CPU. As a result, they'll promote the hack who spewed out this junk to a position working on something important, and the same bad algorithm will get used when it matters, and off we go with the people dying and the lawsuits and the congressional investigations.

  47. Malice? by xlsior · · Score: 3, Interesting

    "Never ascribe to malice that which is adequately explained by incompetence" One thing I couldn't help but notice though, is that Microsoft always pops IE in the number one spot for a moment *before* shuffling the browsers and showing them in randomized order... Very visible if you visit the ballot manually in IE and hit F5 a few times: http://www.browserchoice.eu/

    1. Re:Malice? by Anonymous Coward · · Score: 0

      "Never ascribe to malice that which is adequately explained by incompetence"
      ummmm... why? malice existed for the past few million years. What happened to make it disappear?
      yep, it's a citation. So what?

    2. Re:Malice? by Anonymous Coward · · Score: 0

      And with JavaScript disabled on http://www.browserchoice.eu/, the list is always as follow: "Windows® Internet Explorer® 8"; "Mozilla Firefox"; "Opera Web browser"; "Google Chrome"; "Safari for Windows from Apple"; "Maxthon Browser"; "K-Meleon"; "Flock"; "Avant Browser"; "Sleipnir"; "FlashPeak SlimBrowser"; "GreenBrowser"

    3. Re:Malice? by Anonymous Coward · · Score: 0

      Or if you disable JS, you could clearly notice that the browser order always is IE->Firefox->Opera->Chrome and some other insignificant browsers.

    4. Re:Malice? by Anonymous Coward · · Score: 0

      Incompetence has existed for even longer.

      Attributing this to malice, when the algorithm is biased AGAINST Microsoft, is beyond paranoid.

    5. Re:Malice? by CAIMLAS · · Score: 1

      It does the same in Chrome (well, Chromium nightly), and, I'd assume, all browsers based on Webkit. Chromium/webkit appears to display elements before running of the script elements.

      --
      ~/ssh slashdot.org ssh: connect to host slashdot.org port 22: too many beers
    6. Re:Malice? by Bigjeff5 · · Score: 2, Informative

      It starts off as a list dumbass, the browsers to sort have to come from somewhere.

      Would you be upset if the first item on the list were FireFox, so FF popped up first momentarily?

      Seriously, get a life.

      --
      Security is mostly a superstition... Avoiding danger is no safer in the long run than outright exposure. - Helen Keller
    7. Re:Malice? by Anonymous Coward · · Score: 1, Funny

      I tried that, and IE appeared in the first slot -every- time. Then I realized that I had javascript off. You might try it in Chrome to get an idea of how much faster their javascript engine is on your system.

    8. Re:Malice? by Anonymous Coward · · Score: 0

      That's for all java script disabled browsers... no randomness there.
      And perhaps it drills right into your subconsciousness.

    9. Re:Malice? by Anonymous Coward · · Score: 0

      No it isn't, the last position in the list is the second best for making an impression on the user. So their algorithm puts IE in the second best position 50% of the time. That sounds like a bias towards Microsoft, but subtle enough that it could be passed off as an accident.

  48. Bad Article, Bad Summary by alphabetsoup · · Score: 4, Interesting

    Both the article and the summary mixes up the concepts. Randomness and bias are related but different things. Think of a biased coin loaded in favor of heads - the heads may appear twice as often as the tails, but the distribution is still random. Here too, contrary to the summary's claim of "far from random", the results are random, just biased, and biased against IE, if I may add, which is an important fact the summary omitted.

    1. Re:Bad Article, Bad Summary by DMiax · · Score: 1

      Both the article and the summary mixes up the concepts. Randomness and bias are related but different things. Think of a biased coin loaded in favor of heads - the heads may appear twice as often as the tails, but the distribution is still random. Here too, contrary to the summary's claim of "far from random", the results are random, just biased, and biased against IE, if I may add, which is an important fact the summary omitted.

      I think you are mixing things up. Your biased coin is less random because I can guess more easily what will come out, until it is so biased that it gives always head and is not random at all. You are probably thinking of a bias in the average, let's say equally distributed 0 and 1 is as random as equally distributed 1 and 2. The article concerns entropy, which is orthogonal with the values of the outcomes.

    2. Re:Bad Article, Bad Summary by skelterjohn · · Score: 1, Informative

      Statisticians tend to draw a distinction between "random" and "stochastic". Random means from a uniform distribution - every possibility is as likely as every other. Stochastic just means drawn from a distribution.

    3. Re:Bad Article, Bad Summary by Anonymous Coward · · Score: 0

      @alphabetsoup: Aren't you being unnecessarily pedantic here? What most people assume by randomness is random *and* unbiased. In layman terms your loaded coin isn't giving "random" results. (btw eating Fisher-Yates here for breakfast since many moons).

    4. Re:Bad Article, Bad Summary by Solandri · · Score: 1

      the results are random, just biased, and biased against IE, if I may add, which is an important fact the summary omitted.

      Actually, studies have shown that when people are presented with a list of items, the first and last are most likely to be remembered. So I would hazard a guess that if all choices are equal, the first spot would be most picked, and the last spot would be second-most picked.

    5. Re:Bad Article, Bad Summary by Anonymous Coward · · Score: 0

      Actually, no. Random means that given a function that returns a bit, the probability that bit will be 0 is equal to the probability that bit will be 1. This is basic computer science. If the result is biased, it is not random.

    6. Re:Bad Article, Bad Summary by Simetrical · · Score: 1

      Both the article and the summary mixes up the concepts. Randomness and bias are related but different things. Think of a biased coin loaded in favor of heads - the heads may appear twice as often as the tails, but the distribution is still random. Here too, contrary to the summary's claim of "far from random", the results are random, just biased

      Could people please realize that there are multiple valid definitions of random out there? It's very clear from context that the relevant definition here is "uniformly distributed, unpredictable", not "obeying a probability distribution".

      --
      MediaWiki developer, Total War Center sysadmin
  49. Re:What? Why not? by cgenman · · Score: 1

    Leaving the random number generator unseeded can sometimes produce skewed results. It used to be that you were almost guaranteed to get the same output sequence, especially in optimized languages, as the default seed was some fixed value. This isn't as much of an issue these days, as most get properly pre-seeded with the time or some other variable. But it is still good practice to properly pre-seed your code, especially for old systems / guaranteed randomness / stodgy old manness.

  50. Random, or fair? by straponego · · Score: 1

    Why does it have to be random? If they're not taking into account market share or other factors, evenly dividing the possible permutations of browser order should be more "fair" than a "random" order. So you could cycle the permutations in order based on serial number. The only way this wouldn't work would be if you do multiple installs/selections per OS. In that case, make every install go to the next permutation in the list. You'd have to phone home to track this, but Windows phones home constantly anyway.

    Of course, they'd screw up the implementation of this approach too.

  51. I'm sorry, but WTF dude! by Colin+Smith · · Score: 1

    one would think that a company such as Microsoft that has been owning the software market for decades now would know how to implement a randomizing algorithm correctly.

    WTF? They can't even get their slashes round the right way.

     

    --
    Deleted
  52. Re:I am amazed... by jim_v2000 · · Score: 1

    Yes, because Microsoft is the only company that puts out software with vulnerabilities it in. I suppose that's why my Mac and Linux boxes install security updates all the time too.

    --
    Don't take life so seriously. No one makes it out alive.
  53. Slower than necessary? by Anonymous Coward · · Score: 0

    1 acceptable solution that is slower than necessary

    Good god, they're shuffling an array with 5 freakin elements. The "slow" solution would have been more than adequate. In fact, I would argue it is the best solution since the code would have been simpler and easier to maintain (and quicker to download).

  54. ummm, just how many times by Stan92057 · · Score: 0

    Ummm, just how many times does this man think people will register there new copy of Windows or are people going to be given a browser choice every day/Everytime they bootup?? Sometimes people just take things that don't matter way too far.

    --
    Jack of all trades,master of none
  55. Re:Might be a mistake but not where Rob is pointin by Setsquare · · Score: 1

    Well unless there is something else going on Rob needs to go back to school too. A simple quicksort algorithm with the comparator replaced with a random choice becomes a recursive random partition of the array. A simple inductive argument shows that this will not produce the unbalanced results he found. So the problem is elsewhere (most likely in the RNG seeding or a bias in the pivot selection, if he is running it in a tight loop and the seed is something like, current second, then the same seed may appear several times).

    You do realise that quicksort is whole family of algorithms? Most library routine writers consider it a bug if you sort the same data twice and it comes up in a different order, so they tend to avoid random pivot and use median of 3 or 9 pivot instead. These will give biased shuffling. They also also switch to insertion sort for small subarrays which will lead to biased shuffling.

    Closing the walls partitioning takes 1/2 to 1/3 times as many swaps as the Lomuto partitioning (which is a simple left to right for loop) so it's usually the preferred method to partition. Lomuto also goes quadratic for equal valued elements. Most closing the walls partitions use the pivot as a sentinal, but with a random comparison the indexes can walk right past the end the subarray and generate an array index error.

  56. highschool students can get this right! by AlgorithMan · · Score: 0, Troll

    I developed one of the good implementations in school... god, Microsoft is such a pile of tinkerers! Is there anything they can get right, that a highschool student could not? No, I don't mean marketing, bribing politicians and blocking competition! They exist for 35 years and - heck - they still have problems with leap years!

    sometimes I get the impression that they are trying the "a thousand monkeys on a thousand typewriters" approach...

    --
    The MAFIAA is a bunch of mindless jerks who will be the first up against the wall when the revolution comes
  57. Card shuffle algorithm by 1+a+bee · · Score: 1

    Talking about random shuffles, does anyone know of a shuffle algorithm emulating a "real" dovetail shuffle of a deck of cards?

    In the late 80's, Dave Bayer and Persi Diaconis (Trailing the dovetail shuffle to its lair. The Annals of Applied Probability) showed that 7 shuffles of a deck of 52 was sufficiently random for most purposes. The New York Times ran a story and following a number of critiques showing that the results were not sufficiently random for every kind of application (see New Age Solitaire), I heard no more of this seemingly promising NlogN approach to shuffling.

    1. Re:Card shuffle algorithm by mmmmbeer · · Score: 1

      If you want to simulate a real-life shuffle, it should be simple enough to create an algorithm to do that. I'll give it a shot here:

      1) Cut your deck approximately in half. I'd say that would be maybe half of the deck +/- five cards or so. Use a random number generator to determine how far from the true middle of the deck you cut it. The five is just a guess that I think most people would generally be that close to the middle, but you could go higher if you felt it was more realistic.

      2) Choose a number from one to some (three or four, maybe?) and move that many cards from the bottom of one half of the deck to the top of the merged deck.

      3) Do the same for the other half of the deck.

      4) Repeat 2 and 3 until one side or the other runs out of cards.

      5) Put the remaining cards from the other half on top.

      What do you think?

      Alternatively, you could use the shuffling method my friend Charles uses:

      1) Cut deck as above.

      2) Spray cards everywhere.

      3) Pick up cards and hand them to someone who can shuffle.

    2. Re:Card shuffle algorithm by mmmmbeer · · Score: 1

      Instead of 2-4 above, you could also randomly determine which half of the deck to take the next card from. I think I prefer the one I showed above, since it puts a maximum cap on the number that could come from one side at a time. Also, it occurs to me to point out that if you use the method above, you should always start step 2 using the top half of the deck; otherwise you will always keep the bottom card on the bottom.

    3. Re:Card shuffle algorithm by 1+a+bee · · Score: 1

      If you want to simulate a real-life shuffle, it should be simple enough to create an algorithm to do that. I'll give it a shot here..

      What do you think?

      It's a start. I'm not sure this simulates a real dovetail (rifle) shuffle, but it does seem to capture 2 points of randomization: one, imperfections in halving of deck, and two, imperfections in interleaving the cards from the two halves.

    4. Re:Card shuffle algorithm by 1+a+bee · · Score: 1

      Actually, I like your idea of randomizing which deck to draw the next card from the bottom of better. Simple and effective, and to boot, it addresses the problem of which deck to start from. Interesting!

  58. Reach for Knuth? by fm6 · · Score: 2, Insightful

    And one of the things one learns early on is to reach for Knuth

    Knuth is for computer scientists. Not everybody who writes code meets that definition. A lot of us (and I include myself) don't even qualify as "engineers".

    For most programmers, the best way to write good "select random x from 1..n is not to brush up on our algorithmics. That's like fabricating a car part instead of going to the auto supply. (Hey, there's a good reason the car analogy keeps popping up!) You need to rely on standard, well-tested libraries. Josh Bloch even refers to this use case as an example of why you should rely on library code.

    1. Re:Reach for Knuth? by argent · · Score: 1

      This isn't like going to the auto parts place to get the part you need.

      This is like going to the auto parts place and guessing at the part you need, without knowing what the part actually does.

      Looking it up in Knuth is like looking up the part in the manual BEFORE you go to the auto parts place to get the part.

    2. Re:Reach for Knuth? by fm6 · · Score: 2, Insightful

      Why would you not know what the library call does? Presumably it's documented. Knuth might help you how the library call works, but more likely you'd refer to Knuth to write your own version of the code. And, as Josh Bloch argues, rewriting tried and tested code is a mistake.

    3. Re:Reach for Knuth? by pipedwho · · Score: 1

      The problem is that there probably wasn't a library call for "randomly shuffle array elements".

      So the analogy is more like: you went to get a part for your car, but no one had it available so you decide to jury rig your own out of other spare parts. That kind of attitude gets people killed on the road.

      It all comes down to this: A man's gotta know his limitations.

      If you're just a keyboard jockey, chances are that everything is not going to be straight forward to you. Either you have to constantly ask questions of people that know what they're doing, or you end up taking a risk trying to do it yourself.

      It looks like the guy that wrote the offending javascript used a solution that he found on the web. Unfortunately, not everything you read on the web is reliable. Whereas what you read in Knuth is as reliable as it gets.

    4. Re:Reach for Knuth? by argent · · Score: 1

      Why would you not know what the library call does?

      Same reason you don't know how much to tighten your fanbelt if you don't read the shop manual.

      Microsoft WASN'T just making a library call. They were passing to the library a comparison function that DID NOT WORK, because the specific programmer involved didn't understand how the library call worked.

      Sure, theoretically the library could have cached all the results from the comparison function, but it didn't. They could have cached the results IN the function itself, say by memoizing it. That would have fixed it. But if you don't know what the underlying code is likely to do because you don't actually know what a fanbelt is for you're hosed.

    5. Re:Reach for Knuth? by argent · · Score: 1

      Whereas what you read in Knuth is as reliable as it gets.

      Personally I prefer Horowitz and Sahni. :)

    6. Re:Reach for Knuth? by zill · · Score: 1

      If they had read Knuth they wouldn't be working at Microsoft in the first place.

    7. Re:Reach for Knuth? by fm6 · · Score: 1

      Same reason you don't know how much to tighten your fanbelt if you don't read the shop manual.Same reason you don't know how much to tighten your fanbelt if you don't read the shop manual.

      OK, I've never worked on cars, so correct me if I'm wrong, but the shop manual is the documentation the manufacturer provides for people working on its cars, right? If so, Knuth is definitely not a shop manual, because he makes a point of not talking about specific implementations. If you want to push this analogy a little further (though it won't go much further before it breaks) Knuth is the textbook the guys who designed the engine read. The shop manual is the API programmer's guide.

      Has anybody bothered to read the Josh Bloch page I linked? Because he covers this issue much better than I could.

    8. Re:Reach for Knuth? by fm6 · · Score: 1

      I didn't mean to suggest that there was a library call that did exactly what he needed. My point was that he did some numerical work he should have left to the API. He probably took a real-value random number generator and rounded the result to an integer. The Josh Bloch page I linked demonstrates how this can go wrong and why you should go slightly higher up the stack.

    9. Re:Reach for Knuth? by argent · · Score: 1

      Knuth is definitely not a shop manual, because he makes a point of not talking about specific implementations.

      Knuth is the shop manual for "sorting and searching", or for "data structures". There are other "shop manuals", like Horowitz and Sahni, or other college texts, but they're all similar to Knuth. The API guide isn't the shop manual, the API guide is for someone who has already read the shop manual.

      The API programmer's guide is the instructions on the back of the box the "sort function" comes in. It doesn't tell you "don't use the sort function this way" any more than the fanbelt comes with instructions telling you not to use it as a necktie.

    10. Re:Reach for Knuth? by pipedwho · · Score: 1

      What he seems to have done is to call the Sort() command using a callback to a user definable comparison function. His function instead of returning a valid comparison, just returned a random value. This makes the distribution highly dependant on both the array data and the internal implementation of the sort algorithm. For an algorithm like qsort this will cause the results to be significantly non-uniform.

      Whenever you use a 'black box' API call beyond the obvious intended usage, you open yourself up to all the problems that can befall the inexperienced/undereducated coder. And since most libraries are not sufficiently documented with details of precisely how they work internally, the programmer is left open to all sorts of potential implementation issues.

      The whole problem seems to have stemmed from the fact that the programmer didn't have an appropriate library function available to him, and then proceeded to use an alternative library function in an inappropriate way.

      I have no argument that the best programming approach is to use any available supplied libraries to the maximum extent possible. Which is tempered by how well you understand any individual library's implementation. And you are correct in that supplemental functionality is best performed within the abstracted domain of the library's own methods (wherever possible). But, I believe that in this case the programmer didn't even know he was doing anything 'wrong' when he blindly followed some directions that he probably read on a scripting tutorial website.

      In this day and age of out-of-work qualified coders, there is no good reason for any programmer that you hire to not have at least a basic understanding of computer science. The days of 'cowboy coders' and 'keyboard jockeys' are over. And there is definitely no excuse for this in a corporation like Microsoft that is so deeply entrenched in the computer industry.

    11. Re:Reach for Knuth? by fm6 · · Score: 1

      I should know better to use an analogy on Slashdot. People put all their energies into nitpicking the analogy instead of using the analogy to understand my argument.

      Forget about cars. My argument is this: a good random number library has a simple API call that generates a random number between 1 and n, where n is a parameter. Programmers typically ignore this call and use some arithmetic gimmick to convert the basic random 0.0...1.0 real number to an integer. That can easily go wrong, as you'd discover if you'd read my damn link already and stop talking about shop manuals.

      It's pretty clear that's what happened in this case. Reading Knuth is not going to help you avoid this kind of mistake. And indeed, the kind of programmer who designs simple web applications like this one is not going to get a lot of benefit from from studying algorithms and data structures.

    12. Re:Reach for Knuth? by argent · · Score: 1

      It's pretty clear that's what happened in this case. [gibberish about using the wrong PRNG API]

      No, um, it isn't. It isn't. At all. Go back and re-read the article until you understand it. If the big words are too much, crack open the shop manual (Knuth, H&S, whatever your college algorithms course used) and study the way sort algorithms work until you get it figured out.

      Seriously. You are completely wrong at every level.

    13. Re:Reach for Knuth? by fm6 · · Score: 1

      In other words, if I was as smart as you, I'd understand why I'm wrong, even though you're not smart enough to explain why I'm wrong.

    14. Re:Reach for Knuth? by Anonymous Coward · · Score: 0

      It might sound amazing on slashdot but quite a few developers never heard of Knuth.

    15. Re:Reach for Knuth? by argent · · Score: 1

      If you know anything about sorting, you can see the problem here. Sorting requires a self-consistent definition of ordering. The following assertions must be true if sorting is to make any sense at all:

            1. If aa
            2. If a>b then bb and b>c then a>c
            6. If a=b and b=c then a=c

      All of these statements are violated by the given Microsoft comparison function.

      The problem has nothing to do with whether they generated a random float between 0 and 1 and subtracted 0.5, or generated a random integer between 0 and 2 and subtracted 1. The problem is that

      1. You need to get *the same* result when comparing A to B the first time, and when comparing A to B the second time.
      2. When you're comparing multiple sets of numbers the results need to be well-ordered. If A B and B C then A C.

      If you're just generating a random result for every comparison, then these are no longer true.

      By memoizing the result of the comparison algorithm, you can fix (1), but (2) will remain a problem. And it doesn't matter what "fan belt" you plug in to generate the random numbers, you're still trying to use it as a necktie.

    16. Re:Reach for Knuth? by Anonymous Coward · · Score: 0

      Yup, that's why I get to so much dumb code, written by people who can't even do a proper job of using the libraries! Keep in mind that in this case the buggy code didn't try to implement its own random number generator, it was trying to use the library function for that, along with the library-supplied sort. BUT this poor soul couldn't even combine those two things in a sensible way to produce correct results, and lacking a "shuffle" function in the library he found himself out of plausible solutions. And that's why some people should really abstain from programming: it's not that every problem requires an engineer, it's that some 'simple' problems are more complicated than what is evident at first sight, and if you don't have either the trained eye or trained help you're very soon way over your head!

    17. Re:Reach for Knuth? by fm6 · · Score: 1

      There, you proved that I didn't read the article carefully. I screwed up, I admit it.

      Now, isn't making me say that a lot more satisfying than just yelling "Oh, go read Knuth"?

  59. The author provides another lesson as well by 93+Escort+Wagon · · Score: 1

    At least based on the summary, I'd say the author also provides a really good demonstration of "how to be a smug condescending twit".

    --
    #DeleteChrome
    1. Re:The author provides another lesson as well by Anonymous Coward · · Score: 0

      You're the twit. Read the article rather than being such an ass. Have some pride in your work and do it right. Clearly Microsoft doesn't.

  60. KISS by snevig · · Score: 1

    An array can be easily randomized in JavaScript by simply assigning a fixed random number to each element of the array:

    function randomizeArray(a){var i,b=[];for(i=0;i<a.length;i++)b.push([a[i],Math.random()]);b.sort(randomizeArraySort);for(i=0;i<b.length;i++)b[i]=b[i][0];return b;}

    function randomizeArraySort(a,b){return a[1]<b[1]?-1:a[1]>b[1]?1:0;}


    usage example:

    alert(randomizeArray(["a","b","c","d","e"]));

  61. what exactly is the problem anyway? by Golden_Rider · · Score: 1

    I do not understand the problem. Why is it "bad" if one of the browsers appears on the far right side instead of the far left side? I know it would not influence my choice, what WOULD influence my choice is if I had heard from friends/colleagues etc about one or more of the browsers before. Whether Firefox is on position 2 or 3 or 4 is totally irrelevant. Maybe they could just present the browser choices in a big circle instead of a horizontal list ...

  62. Re:Might be a mistake but not where Rob is pointin by ma_luen · · Score: 1

    Yes I am well aware of this, in my post I state a "simple quicksort" algorithm which precludes several of the issues you mention and I discusses the possibility of problems in the pivot selection. But as you will note the article does not discuss any of these issues so we have no idea if it is one of these or not (it just claims it must be the sorting).

    So we basically have an article that says I ran a benchmark and I can't explain the results so I'll just make up something that sounds good.

  63. Genuine question.. by Anonymous Coward · · Score: 0

    This is the result of a government mandate.

    Why on earth did said mandate not specify what method was being used to sort the browsers? Surely it gave parameters for inclusion in the list...

  64. Re:Might be a mistake but not where Rob is pointin by IWannaBeAnAC · · Score: 1

    Wow, did you 'graduate' from the same school as the Microsoft programmer who wrote this code?

    The sort function requires that the comparison function defines a strict weak ordering. Anything else violates the precondition, and the result of calling sort with a bad comparitor is completely unspecified. Not long ago on comp.lang.c++.moderated there was a query from someone complaining about what appeared to be a bug in their standard library sort() function, which was consistently crashing. It turned out their comparitor was faulty, and the sort function was rolling off the end of the array and accessing beyond the array bound.

  65. Well, MS may as well change it anyway. by I'm+Don+Giovanni · · Score: 1

    Simply assign each browser a random number, then sort them by each corresponding number. The current solution is over-engineered. It's till random, but lacks an even distribution of probability. They should make the very simple change to "fix" that, if for no other reason than just to be beyond reproach.

    --
    -- "I never gave these stories much credence." - HAL 9000
  66. So what? by Anonymous Coward · · Score: 0

    Is it just me, or does everyone find this extremely irrelevant...seeing as I've already made my browser choice. This only affects "first-time computer users," really....which should be less than 1% of the European population by now. Is Europe so short on teenagers to set up their (gran)parents' new computers that we need to worry about the noobs?

  67. Re:Might be a mistake but not where Rob is pointin by ma_luen · · Score: 1

    Most likely I graduated from a different school but I appreciate that you asked.

    You are quite right the formal precondition of the sort method is violated and this implementation is quite sketchy in that respect. However, that does not tell us what the distribution errors are caused by. As Rob is making other strange statements like possible non-termination (which should be impossible in any reasonable quicksort), I am not particularly happy to just believe him without a more careful analysis (e.g. seeding, how the test harness was implemented, pivot selection, etc.).

  68. standards, never followed them, never will by dltaylor · · Score: 1

    Three things would be needed for Microsoft to implement an effective random selection:

    a spec' to follow the "standard"

    a competent programmer

    management willingness to let the programmer follow the spec'

    Starting back with C-80 (a CP/M-80 attempt at a "C" compiler), Microsoft has consistently demonstrated that their organization lacks at lest one of those attributes.

    int t_array[16];
    int *t_pointer = &t_array[0];

    however, in C-80 (t_pointer != t_array).

    The Amiga programmers guide specified that addresses were 32-bit (68000), and not to store any data (flag bits, whatever) in the upper byte. Microsoft stuffed flags into the upper byte when implementing Amiga Basic, which promptly broke everything when the 68020 bonded out the upper address byte.

  69. You think that's bad? by Anonymous Coward · · Score: 0

    Try visiting the page with javascript disabled. You'd expect to see a message along the lines of "this page requires javascript to display correctly", right? But of course, that's not what you get in this case...

  70. Knuth's Quote Re: Random Number Generators by wintermute3 · · Score: 2, Funny

    I always liked Knuth's choice quote from John von Neumann on the subject:

            "Anyone who considers arithmetical methods of producing random digits is, of course, in a state of sin."

    - Michael

  71. Wow. Good Find. by I'm+Don+Giovanni · · Score: 1

    I wonder how many javascripts on the web are using this same flawed random sort implementation? Probably lots.

    --
    -- "I never gave these stories much credence." - HAL 9000
  72. This is javascript code? by jmbtsang · · Score: 1

    One particular web developer is less intelligent than your average CS major. News at 11!

  73. Eheh by SmallFurryCreature · · Score: 1

    So a billion dollar company is safing a few pennies by not using a proper routine, that they probably got developed and ready to use in any case and instead produces out of several approaches the one that is bad.

    And that doesn't tell you anything.

    Well, that tells me something about you. Can you guess what it is?

    --

    MMO Quests are like orgasms:

    You may solo them, I prefer them in a group.

  74. To me it is exactly what MS is about by SmallFurryCreature · · Score: 1

    This ain't hard and MS has got (or should have with the salaries they are paying) plenty of smart people. And yet they continue to screw things up time and after time. And this is not a compatibility issue were MS has to ensure its software runs on a billion different configurations with users disabling critical stuff because they think they know better. This is just a random selection, a text-book case and they get it wrong...

    And those who claim about MS not wanting to spend countless resources on this. Sorry, but any decent dev would have knocked this out in a day. Give a week of testing and we are still talking peanuts in development cost for MS. That they still didn't get it right. Well that says a lot about MS. It always seems to be a race towards the bottom for them. With every product, everything they do, you got to wonder, what did they screw up this time.

    IE5 mobile browser without CSS. X-box that is underpowered. New music store for the zune so that existing stores and music don't work. New x-box with a failure rate that you couldn't get if you dropped half the boxes during transport.

    And if they can't even get the right random algorithm, how can we be sure they get anything else in their code right? Would you buy a car if the car radio fell out whenever you turned it on? No, because it says something about quality. If the things you can see, don't work, then what about the things you can't see?

    --

    MMO Quests are like orgasms:

    You may solo them, I prefer them in a group.

  75. Re:Modulo by UBfusion · · Score: 1

    It's not modulo 5, it's modulo 5! (the number of possible permutations of N items is N!=1.2.3...N)

  76. Re:Might be a mistake but not where Rob is pointin by IWannaBeAnAC · · Score: 1

    You are still confusing idealized algorithms with real-world implementations. Where in the javascript specification does it say that the sort() function must use QuickSort? And even more specifically, where does it say that the QuickSort implementation will coincide exactly with the idealized version you learned in CS101 ?

    In practice, implementations of sort() generally use something other than QuickSort whenever the array (or partition) is smaller than some (small) fixed size. This is because using QuickSort to sort a very short array is actually quite slow, much slower than other algorithms (consider for example the sequence of operations performed by QuickSort on an array of 3 numbers, compared with a simple hand-coded direct sort). So, even if the Javascript implementations in question are using an algorithm based on QuickSort for large arrays, it is quite likely that for the array of 5 numbers it is using a completely different algorithm. How are you to know whether that algorithm is guaranteed to terminate if given ill-formed input?

    that does not tell us what the distribution errors are caused by

    Huh? The distribution errors are caused by the comparitor, that violates the precondition for the sort() function. Full stop, end of story. The actual distribution will be likely depend sensitively on the details of the sort implementation, which it almost certainly the case is since it appears to be a different distribution for every browser. If you can get hold of the source code of the javascript interpreter you might be able to see how sort() was implemented in a specific case, and understand how the actual distribution arose, but that isn't a very useful thing to do. It may well change in the next 0.01 version of the browser anyway.

  77. Re:Interesting that random compare is not random.. by petermgreen · · Score: 1

    Pretty much any technique I can think of
    One that comes to mind that could potentially run forever with a sufficiently fucked comparison function is a naive bubble-sort that doesn't bother with the optimisation of reducing the list size with each pass and uses a pass with no changes as the terminating condition.

    --
    note: i'm known as plugwash most places but i screwd up registering that here somehow in the past and now can't register
  78. Randomness vs Uniformity by UBfusion · · Score: 3, Insightful

    Those of you that are computer scientists should take a moment to consider that randomness is not the same as uniformity (as an insightful reader commented in TFA and triggered me to respond there).

    Just because the only way to produce an algorithm for uniformity is via a random number generator, this does not mean that there aren't other non-statistical approaches. Here's one:

    "The computer upon Windows installation contacts a MS site that uses a global installation counter - each new installation would increase the counter from N to (N+1) and then present a browser order according to (N modulo 5!). This is a totally deterministic process, with no randomness at all (statistical tests for randomness would fail because of the autocorrelation), which however would lead to perfect uniformity: at any given time instant, each browser would have been placed in each of the 5 positions with a percentage of precisely 20%, as required. The same kind of uniformity could be produced by using the installation serial number (licence) of Windows: since the licence key space is well-defined, the order of browsers could be also well (uniformly) defined from the serial number itself. There might be a problem with volume licences, but VLKs are a small percentage of total installations.

    However, on a single offline computer, with no knowledge of history (what ballot was presented globally) or without a licence key, programmers have to resort to mathematics in order to produce
    uniform (not necessarily random) distributions. This is an application of the law of large numbers: if the ballot is uniform on the same computer, it will be uniform globally." (using quotes because I'm quoting myself).

    In conclusion, we should not care if the distribution is not "random" but whether it is uniform (i.e. all possible permutations of 5 browsers appear with equal frequencies).

  79. Re:What? Why not? by Bigjeff5 · · Score: 1

    We now know a shuffling algorithm should have been used and Microsoft could have evaded prosecution

    Wow, I didn't know the EU already brought another anti-trust suit over this!

    Oh wait, they didn't, who are you to say this function isn't sufficient to protect them from further prosecution? As I understand it, all they had to do was present a list of browser choices instead of just loading their own, and not choose the order of that list ahead of time. Of course, any list is going to have an order of some sort to begin with, so a simple random function accomplishes that goal.

    There is a distinction that needs to be made here, it's a bit of a semantic but it is important nonetheless: It is not Microsoft's responsibility to "promote competition" against themselves. It is Microsoft's responsibility to not abuse their position of market dominance to unfairly disadvantage their competition in order to drive them out of the market. The EU felt that installing IE as the default browser on Windows was unfairly restricting a scarce resource to gain competitive advantage. As such, IE cannot be the default browser, and users must be given a choice from a list not chosen ahead of time.

    You can't honestly argue that they are unfairly limiting a scarce resource in order to gain an unfair advantage because of a 50% chance they'll be the end option among four other options, can you?

    You guys seriously need to get some perspective. I know it's fun to bash the big company, but seriously, it gets old after a while. Just keep them in line, that's all that's needed.

    --
    Security is mostly a superstition... Avoiding danger is no safer in the long run than outright exposure. - Helen Keller
  80. Re:Might be a mistake but not where Rob is pointin by petermgreen · · Score: 1

    Is there any guarantee that the sort algorithm the browser uses will be a quicksort?

    --
    note: i'm known as plugwash most places but i screwd up registering that here somehow in the past and now can't register
  81. Re:Interesting that random compare is not random.. by SuperKendall · · Score: 1

    That's a good point, in fact since a plain bubble sort requires a pass with no changes I think it would run for a very long time indeed...

    No sort called from a library would be using Bubble Sort though, if you're going to the trouble to build an API with a comparator your sorting algorithm should be half decent.

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley
  82. Better than you think by SuperKendall · · Score: 1

    Safari will almost always (almost 50% of the time) be put in the bottom two elements [out of five].

    Very funny, but you ignore the fact that between the two different browsers "bottom two" really equates to one exact position in each case. Sure "almost always" is probably not a good description but even 40% is a lot more than 20% no matter how you figure it.

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley
  83. Single out of two by SuperKendall · · Score: 1

    Wow... the bottom 2 elements out of a possible 5 ALMOST 50% of the time.

    Read the results. It's really ONE out of five, it's just that the position changed depending on the browser that was performing the test. So it's not two out of five, it's one out of five - it's just which one is the chosen slot can alter based on the algorithm used.

    Yes, 40% is far different than 20%.

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley
  84. Re:Might be a mistake but not where Rob is pointin by ma_luen · · Score: 1

    I agree with your general point. The particular implementation was not good. Violating method contracts leads to bugs. Yes, obviously. But issue was poor distribution in the random numbers. And the author never determined why this was the case. Was it the implementation of quicksort, an issue with seeding when run in a tight test harness, as you mention does it used different sorts for different input sizes, etc?

    So yes, we have a program that is poorly written and produces the wrong answer. We also have an article that is poorly written and does not explain why the results are what they are (other than don't violate method contracts, which is good advice but not very enlightening).

  85. Re:Might be a mistake but not where Rob is pointin by ma_luen · · Score: 1

    No there is no guarantee and the article does not specify which sorting algorithm is actually used. But any reasonable sorting algorithm should terminate very quickly even with the incorrect comparison function. Which is one of the reasons I found the article annoying, lots of general claims but very little analysis in the end.

    I usually don't post much but for some reason the article struck me as designed to have just enough technical content to seem authoritative but that the intent was simply a chance to get in some cheap shots at Microsoft.
     

  86. Corporate Randomness by NicknamesAreStupid · · Score: 1

    Microsoft was one a start-up, where asking for forgiveness was the rule and the best results trumped the right way. Now it is a Fortune 100 multinational corporation, a'la Exxon. The rule is "ask for permission," and performance reviews are managed by an HR department the size of Twitter. I suspect that someone from Legal now approves the "randomness routine." Lest you think I jest, I bet they have a patent pending on this infamous algorithm.

  87. Even less random by shird · · Score: 1

    What I find even worse than the 'non-randomness' of the choice screen, is that the choices are shown in a fixed order as the page is downloaded and prior to the script being run. This can take several seconds, depending on your connection speed etc. This is more than enough to read the first couple of entries and make your choice.

    Internet explorer 8 is the first choice in the fixed order that you see while the page is downloading.

    http://www.browserchoice.eu/BrowserChoice/browserchoice_en.htm

    They should have the options as 'visible=false' until they are randomly sorted, then make them visible.

    --
    I.O.U One Sig.
  88. Because I read Slashdot? by SuperKendall · · Score: 1

    How do you know?

    Because I've not been living under a rock for the past year or so? Did you honestly read NOTHING about the whole EU case against Microsoft and the resolution?

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley
    1. Re:Because I read Slashdot? by Anonymous Coward · · Score: 0

      Nope, I was too busy being Super! Thanks for asking.

  89. Just slashdot by rgmoore · · Score: 1

    Failure to understand the article isn't really fucking up. It's standard Slashdot practice.

    --

    There's no point in questioning authority if you aren't going to listen to the answers.

  90. Re:Might be a mistake but not where Rob is pointin by IWannaBeAnAC · · Score: 1

    Did you actually read the article?

    But issue was poor distribution in the random numbers

    No, the random numbers themselves were just fine. If there was a problem with the random number generator, then the results in the section 'Fixing the Microsoft Shuffle' in the article would have not produced a uniform distribution.

    The real problem is explained clearly in the article:

    If you know anything about sorting, you can see the problem here. Sorting requires a self-consistent definition of ordering. The following assertions must be true if sorting is to make any sense at all: [...snip definitions of less-than and equivance operators...] All of these statements are violated by the given Microsoft comparison function. Since the comparison function returns random results, a sort routine that depends on any of these logical implications would receive inconsistent information regarding the progress of the sort.

    Garbage In, Garbage Out.

    If you want to analyze the behavior of a specific implementation of an algorithm given input that violates the preconditions, then lookup the source code for your javascript interpreter. That may be a fun exercise to do, if you are bored, but it isn't very illuminating unless you want to understand why browser X produced that specific distribution. If you call sort() on data that doesn't satisfy the requirements of a comparitor, then you are not actually sorting the data. You can follow through the algorithm and see what it would do instead, but for sure it isn't sorting it. Consider for example the behavior of a typical hand-coded routine for sorting an array length 3 (sorry about intending, can't figure out how to get it to work properly in ecode):

    sort3(a,b,c)
    {
    if (b < a)
    {
    if (c < b)
    {
    swap(a,c);
    }
    else
    {
    swap(a,b);
    if (c < b) swap(b,c);
    }
    }
    else
    {
    if (c < b)
    {
    swap(b,c);
    if (b < a) swap(a,b);
    }
    }
    }

    For an exercise, try following through the probabilities of each outcome, if we replace the comparison operation with a coin toss. An unbiased random shuffle should have an equal probability of producing each permutation of the array. For 3 numbers, there are 6 possible permutations so each outcome should have probability 1/6. Is that satisfied here? (hint: no!) Try the same exercise with [insert your favorite sort algorithm here]... Try it with bubble sort too. That is probably what Rob had in mind with the 'may cause infinite loop' comment.

    Unless you have some non-garbage to contribute to this discussion, I'm out of here.

  91. I Hate Garbage, MS Included by Anonymous Coward · · Score: 0

    Can't we go ONE WEEK without a Microsoft story hitting the front page? Seriously, how many shills do they have working here?

  92. Strange by PPH · · Score: 1

    Microsoft didn't seem to have this much trouble generating random numbers when they wrote Excel.

    --
    Have gnu, will travel.
  93. The root of the problem... by zill · · Score: 3, Insightful

    This error can be easily traced back to the first google result (Actually it should be the first bing result in this case).

    To be perfectly honest, this is exactly what I would have done too.
    It takes 5 minutes to dig out my copy of Knuth.
    It takes 1 minute to pirate Knuth and search through the pdf.
    But it only takes 10 seconds to copy and paste this one-liner from the first google hit.

    That probably explains my lack of success in the job market for the past decade...

  94. Yes, that's the initial ordering by imtheguru · · Score: 1

    One thing I couldn't help but notice though, is that Microsoft always pops IE in the number one spot for a moment *before* shuffling the browsers and showing them in randomized order... Very visible if you visit the ballot manually in IE and hit F5 a few times: http://www.browserchoice.eu/

    Yes, that's the initial ordering and very visible if one turns off Javascript (NoScript).

    Internet Explorer 8
    Mozilla Firefox
    Opera Browser
    Google Chrome
    Safari
    Maxthon
    K-Meleon
    Flock
    Avant Browser
    Sleipnir
    FlashPeak SlimBrowser
    GreenBrowser

    --
    Yet Socrates himself is particularly missed.
    A lovely little thinker but a bugger when he's pissed.
  95. Who Cares? Get A Mac... by Udigs · · Score: 1

    Or at least download a copy of Linux. There. Problem solved. Time for lunch.

  96. Re:Interesting that random compare is not random.. by brantondaveperson · · Score: 1

    For very small sorts (four or less I think) bubble sort is actually more efficient than other more advanced algorithms. So it could get used under some circumstances.

    Or at least, I read that it was more efficient once in a book somewhere. Perhaps that is no longer true.

  97. Re:What? Why not? by Anonymous Coward · · Score: 0

    I, too, was amazed. Instead of choosing some easy, if slightly tedious, solution, which would be very trustable, they chose some idiotic solution that risks infinite loops at unpredictable times. I might be moved to finally admit there is some purpose to having math education in CS -- to try to avoid this kind of really dumb programming.

  98. Re:What? Why not? by Anonymous Coward · · Score: 0

    Well, the code might be easier to understand if you're using a high level language that has push and delete from array commands. Or it would be if the poster hadn't screwed up the explanation...

  99. Re:Might be a mistake but not where Rob is pointin by IWannaBeAnAC · · Score: 1

    any reasonable sorting algorithm should terminate very quickly even with the incorrect comparison function

    What gives you that idea? Ideally, if you supply an invalid comparitor to a sort function, then a quality implementation will do whatever is best to aid debugging (especially if it has a debug mode activated). Some examples of what I would expect: crash with a segfault and activate a debugger; throw an exception; go into an infinite loop and wait for a programmer to attach a debugger.

    The worst possible case would be to execution to continue as if there was no error, when in fact the postcondition of sort() is not satisfied and the state of the program may be logically inconsistent.

  100. Weird by Evelas · · Score: 1

    So people keep saying press F5 to see the unsorted order, and I went to try it (after allowing javascript), and when I refreshed I got: Google Chrome image - Google Chrome Firefox image - Safari Firefox image - Firefox IE - IE Opera - Opera and after about a 2-3 second pause, staring at that, the first Firefox image changed to the correct Safari one

  101. Where did you learn statistics!? by Anonymous Coward · · Score: 0

    > "99.99% random" process into a "100% random"

    Did you look at the same stats I did?

    Incorrect: X-squared = 13340.23, df = 16, p-value 2.2e-16
    Fixed Version: X-squared = 21.814, df = 16, p-value = 0.1493

    It's not 99.99% random. It's way off. But you don't know what any of those numbers mean, do you? Or are you going to go Google them?

  102. Re:What? Why not? by darkshadow88 · · Score: 1

    Out of curiosity - why would they need to seed the random number generator?

    Wouldn't -not- seeding it be better? That way MS don't have to include some seed number in their script and have everybody thinking they're manipulating the results by using seed numbers that they know would generate a certain ordering in various versions of IE.

    If you don't seed a random number generator, you get the same sequence of values every time. As it happens, the Javascript random function seeds based on the current system time, which is usually sufficient when you don't need your randomization to be cryptographically secure. So you're right that the programmer should not need to specify a seed in this case, but the fact is that the RNG is seeded behind the scenes (by necessity). Also no competent programmer would ever hard code a "seed number" in their script, as you suggest, as it would be just as bad as having no seed--you'd get the same sequence each time. Ordinarily, if you're manually seeding (and, once again, not doing cryptography), you use the system time just as Javascript automatically does.

    That said.. odd method of getting random results out of an array.. I'm sure it's more efficient...

    Efficiency doesn't matter when you're doing it wrong.

  103. better than random by epine · · Score: 1

    Not only is this solution "good enough", from an anti-trust standpoint it is probably far better than a truly random function.

    Obviously dude INAL, but he seems to think he's a judge and speaks for Europe. If the European court wished to have Microsoft innovate "better than random" they could have asked for this solution directly, or Microsoft could have proposed it formally. Anything less is flirting with contempt of court. To think that they pay their junior legal representation on the order of $300/hour just to ask the judge if they might please submit such a request, the idea that they elected to go with "good enough" to save 15 minutes of programming effort that a high school intern could have done better boggles the mind.

    But thanks for the faux MBA. After Canada won the hockey game (woohoo), I hung around for the free Texas Hold'em, my first game in real life with strange drunks. In this game, you got a special chip for each beer consumed prior to the game. This chip was worth a SB on any round of play. The guy with seven of these white chips couldn't even properly count out a raise of 1000, but he did offer some excellent business advice while he fumbled around.

    Another guy with a big stack of white bonus chips sees my 20 BB raise from early seat with his suited J2 (I'm holding the big slick), stays with me after I go all-in hitting an ace on the flop, then busts me out when he hits his flush draw on the river.

    Then I return home to a troll paean that Microsoft's formal incompetence is "better than random". Some days you can't win.

  104. Re:Interesting that random compare is not random.. by jrumney · · Score: 1

    The act of determining whether it is likely to be more efficient probably wastes more CPU cycles than are saved by switching sort algorithms. Anyone who builds in the optimisation of using a bubble sort for extremely small data sets is a clueless idiot when it comes to the overall picture.

  105. Quality Standards by LtGordon · · Score: 2, Funny

    I bet if we gave this same problem to 100 freshmen computer science majors, at least 1 of them would make the same mistake.

    Well, that seems an awfully high standard for Microsoft to hold itself to.

    Microsoft: Ranked 1st percentile with Freshmen CS Majors

  106. Oblig by LtGordon · · Score: 1

    int placeInternetExplorer()
    {
        return 1;  //chosen by fair dice roll
    }

  107. And what about apple? google by Anonymous Coward · · Score: 0

    Maybe Im wrong,, but do Apple offer a choice of browser, with a random selection on a new os? Im sure that they don't.

    It seems half the things MS are criticized for, actually the competition do also.
    Choice of Browser on default install
    Backwards compatibility (try getting the latest mac os on a mac mini...)
    Sharing drives (NTFS shared portable drive on a MAC / With a PC.

    Pot calling the kettle black..http://developers.slashdot.org/comments.pl?sid=1566166&op=reply&threshold=1&commentsort=0&mode=thread&pid=

  108. Parent Comment Improperly Modded by Anonymous Coward · · Score: 0

    How the hell is the parent with a quote from TFA and a funny comment on that off-topic?

    Looks like an MS troll did modding.

    Slashdot really needs to fix the moderation and boot anybody who uses it for improper reasons.

  109. Browser selection by Rammed+Earth · · Score: 1

    Why Microsoft is required to put a browser selection list at all is beyond me- do we require Toyota to offer GM, Ford, or Chrysler wheels when selling new cars? I see it as the same issue.

  110. Sorting is OK by Otis_INF · · Score: 1

    if you never use the same random number twice. Sorting fails because if two or more elements have the same 'random' number assigned to them, they won't switch places compared to the other elements compared to whatever numbers the rest has. This means that it's less optimal.

    So calling sorting a non-optimal randomization technique isn't always valid: assigning unique random numbers to the elements does work.

    --
    Never underestimate the relief of true separation of Religion and State.
  111. MS's other venture into JS: by dushkin · · Score: 1

    SourceGuard: whenever you right-click, a message pops up. Enterprise level source-code protection for commercial websites. Compatible with their IRM(TM) technology (Education discounts available)

    tons of R&D, you guys!

    --
    o hai
  112. Re:What? Why not? by Stephen+Samuel · · Score: 1
    If this 'random error' came out of a two-bit fly-by-night operation putting together a proof of concept, I might accept that it was just an oops, but that's so far from describing Microsoft that it's not even worth considering.
    • this came out of Microsoft, a company with almost infinite resources.
    • Microsoft has a history of 'errors' that turn out to be to the detriment of their competition (some later proven to have been malicious.
    • This whole antitrust process has taken place at the highest levels of the company. It's highly unlikely that this page was 'just thrown together' without massive high, middle and low management input and oversight into the design.
    • It puts IE mostly in the most preferential location (first or last in a horizontal choice panel)
    • this is such a mind-numbingly and trivially 'bad' implementation, that the summary points out that you could probably [only] find one programmer that stupid in a freshman computing class.
    • even if this was a random mistake, the chances are only 1 in 5 that IE would have randomly been given the starting position that gave it this most preferential outcome.
    • I don't know about you, but me and my friends figured out, by grade 1, which starting points of 'enie, meanie, miney, moe' gave the counter the preferential result for small numbers of players (less than 6)

    One simple, if cynical, explanation for how this occured is that someone at Microsoft came up with this simple, but predictably bad, implementation and then they figured out which starting position gave IE the best final position and that's the order that went out to production. It would have taken less than a programmer-day of experimentation to figure out which input array gave the optimal distribution and that kind of investment is completely worthwhile given what Microsoft sees as being at stake here.

    For a country^W company with a history like Microsoft's, there's really no reason to be cutting them slack on a high-stakes 'error' that resolves in their favour -- In fact, it's a combination of such 'errors' that put them into the sights of anti-trust investigators in the first place.

    Finally -- even if this was the result of massive managerial oversight, the error is now in the open, and the fix is (a)almost trivial, and (b)available on Wikipedia.
    if MS doesn't fix this problem now, then I'd cite that refusal as evidence that the 'error' is really intentional.

    --
    Free Software: Like love, it grows best when given away.
  113. Comment removed by account_deleted · · Score: 1

    Comment removed based on user account deletion

  114. Re:Might be a mistake but not where Rob is pointin by ma_luen · · Score: 1

    If you want to analyze the behavior of a specific implementation of an algorithm given input that violates the preconditions, then lookup the source code for your javascript interpreter. That may be a fun exercise to do, if you are bored, but it isn't very illuminating unless you want to understand why browser X produced that specific distribution.

    Yeah that is exactly what I wanted because the article was about why a particular javascript implementation produced a poor distribution for the browser selection screen in the EU browser ballot. That is a specifc bug in a specific implementation.

    I can tell you that failure to do array bounds checking before loads/stores will lead to bugs as well. But that does not explain why a specific bug exists. If you want to discuss poor programming practices that is fine but I did not find this a very enlightening way to do it.

    And if you run bubble sort, as described in basic algorithms, it will always terminate (regardless of the comparator) since progress is always made via the loop indexing. In fact termination is often not a function of the loop body behavior. One only needs to show that there is an order (which is not infinitely decending/asscending) on some function of the program state in order to ensure termination. For bubble sort this is just the order on the loop index counter (i).

  115. Re:Might be a mistake but not where Rob is pointin by IWannaBeAnAC · · Score: 1

    Yeah that is exactly what I wanted because the article was about why a particular javascript implementation produced a poor distribution for the browser selection screen in the EU browser ballot. That is a specifc bug in a specific implementation.

    No, the bug was not in any specific implementation of Javascript. The bug was in the code that called sort() with invalid input. It is unreasonable to expect that a function will do what you want it to do, if what you want is outside of the specifications of the function. Here is a challenge for you: produce a sort function, that functions as a usual sort function when provided with a comparitor that defines a strict weak ordering, but when supplied with a comparitor that produces random coin toss output produces an unbiased random shuffle. I think you will have great difficulty doing this! It will almost certainly result in a non-optimal function.

    I can tell you that failure to do array bounds checking before loads/stores will lead to bugs as well.

    No, that is very rare indeed. The only times where lack of array bounds checking is an actual bug is where the index into the array is not well controlled (eg, it came from user input). In 99% of cases, the index into the array is some previously computed value, and if it happens to lie outside the array bound, then an error has already occurred, somewhere prior to the array indexing. That doesn't mean that array bounds checking isn't useful: it is very useful, but the bug that led to the array index out of bounds has already happened by the time the indexing itself occurs. It is only a diagnostic tool, like a CCTV camera recording the identity of a murderer - by the time you see the recording, the murder already happened.

    And if you run bubble sort, as described in basic algorithms, it will always terminate (regardless of the comparator) since progress is always made via the loop indexing.

    The usual implementation of bubble sort keeps a flag to indicate whether any swaps were performed on the current iteration. If no swaps were performed, the algorithm exits because (for a well defined comparitor) the array must be in order. Keep looping until no swaps were performed.

    It is also possible to loop for exactly N iterations, because it can be proven (again, for a well defined comparitor) that at most N iterations will be performed. But this is slower on average, because it ALWAYS performs O(N^2) iterations, whereas if you check the number of swaps and terminate once the array is in order, the average case can be less then O(N^2). For example, if the array is already sorted, the algorithm can exit after 1 iteration.

  116. Re:Might be a mistake but not where Rob is pointin by IWannaBeAnAC · · Score: 1

    because it ALWAYS performs O(N^2) iterations

    Sorry, that wasn't clear: I meant to say O(N^2) operations. I'm using the convention that a single iteration of bubble sort is a loop over all the elements in the array, comparing (and optionally swapping) elements a[i] and a[i+1], so that each iteration is O(N) operations. The complete bubble sort is, for worst case, O(N^2) because it takes in worst case ~N iterations.

  117. Re:Might be a mistake but not where Rob is pointin by ma_luen · · Score: 1

    Look, I agree with you on mis-using the sort routine. Using a method to do something unintended does not cause bugs, it makes them more likely and is bad form. But without further analysis it is not certain if and why the sort is the source of the bug.

    As for your challenge see the first example of quicksort from wikipedia:

    --------
    function quicksort(array)
        var list less, greater
        if length(array) 1
            return array
        select and remove a pivot value pivot from array
        for each x in array
            if x pivot then append x to less
            else append x to greater
        return concatenate(quicksort(less), pivot, quicksort(greater))
    ------

    Note that this correctly implements quicksort. By induction on length we show the uniform distribution:

    length = 1: trival.
    length = 2: a 50/50 comparison has a 50% chance of producing either order.
    length = k: Each element has a 50% chance of being in less and a 50% chance of greater. By induction we will get permutations of each of these uniformly. Since we have a uniform chance of putting each element in each of these (and pivot is selected uniformly at random) the combination of the three will produce all purmutations with equal probability.

    So if you want to argue the effects of possible implementation details then that is fine but that was my point. These implementation details are key to determining what actaully caused the problem (which as shown above may not be the sort at all). The article never addresses these only says the problem must be there, then after changing multiple things the problem isn't.

  118. Original research on Wikipedia ?? by RockDoctor · · Score: 1

    FTFA:

    I tested with that algorithm, using a JavaScript implementation taken from the Fisher-Yates Wikpedia page,

    I'm just off to RTFWP, but why should that stop me from questioning - wouldn't the posting of an implementation of an algorithm in language-X onto a Wikipedia page constitute "original research", and therefore require to be taken back down. (If it's not original, then it must be a copy of something from somewhere, which then becomes a copyright problem)?

    OK, off to RTFWP ... and sure enough, the algorithm implementations are there, and no source is cited. So, surely this is original research and should be struck out (along with all other similar examples).

    --
    Birds are not dinosaur descendants;birds are dinosaurs, for all useful meanings of "birds", "are" and "dinosaurs"
  119. Re:Might be a mistake but not where Rob is pointin by IWannaBeAnAC · · Score: 1

    My god, how many times do we have to go over the same ground?

    Using a method to do something unintended does not cause bugs, it makes them more likely and is bad form.

    I don't know what to say here. If you really believe this, I don't think there is much more to discuss, as we are clearly operating on different wavelengths (and I hope you never ever get a job as a computer programmer!). Consider another example:

    function sqrt(x).
    Precondition: x is a positive real number.
    Postcondition: result' = a positive real number such that result' * result' = x

    Your statement is "Using a method to do something unintended does not cause bugs, ...". Do you really think that calling sqrt(-1), given that specification above, is not a bug?!?! If you do think it is a bug, can you explain how this example is different to the one in the Browser selection box, where a function with a specification

    function sort(array, comp).
    Precondition: comp is a comparison function that defines a strict weak ordering on array.
    Postcondition: array' satisfies comp(array'[i], array'[i+1]), for i=0,1,...,N-2, where N = length(array).

    is called with a comparitor comp that doesn't satisfy a strict weak ordering?

    You might be correct, that the naive quicksort algorithm as presented on Wikipedia would actually produce a proper random shuffle, if given a `coin toss comparitor' as input. But my point still stands: the naive algorithm isn't optimal, because you can do better than choosing random pivots, and also for small arrays quicksort is inefficient anyway. In any production implementation of quicksort, it isn't going to recurse all the way down to length 1 arrays, rather it will stop at length 3, or maybe more, and use some other sort function on the short array.

    If you don't choose the pivots to be uniformly distributed, the resulting shuffle is biased. For example, if you choose the middle element to be the pivot, then on an array of length 3, ABC, with B as the pivot element, you get ACB,CAB,BAC,BCA each with probability 0.125, and ABC,CBA with probability 0.25. There is nothing in the specification of QuickSort that says that this is an invalid implementation! Note that the Javascript doesn't even specify QuickSort as the algorithm to begin with. The chances of any browser implementing the Javascript sort function via the exact implementation of QuickSort that you wrote above essentially zero.

  120. Without javascript by shuperkiwi · · Score: 1

    IE is #1 if you have javascript disabled. How random!

  121. "They're not gonna get us! Na-na-na-n-na-aarrghh!" by MenThal · · Score: 1
    Never mind this browser malarkey! Someone fix the random shuffle in my Prius stat!

    It has a CD with neary 200 MP3s on it, and for some insaaane reason it is very fond of playing Tatu's "They're not gonna get us"...which I'm not sure how got on the CD in the first place... *mumble mumble*

    So I start the car, there it is. I press next a few times, find nothing I like, and hit the Random button again, and guess what. I have heard nothing but Tatu and Madness songs for two fricking weeks to and fro work, and now I'm borderline certifiable.

    I can only hope the cruise control / pedal issue offs me before the CD player breaks my remaining will to live.

  122. Re:Might be a mistake but not where Rob is pointin by ma_luen · · Score: 1

    You do realize there is a difference between code that is dangerous (but technically correct) and code that is actually buggy. As per my quicksort example. Dangerous, but correct.

    You are getting intent and results confused. Calling my quicksort routine with an invalid compare function clearly violates the intent of the contract abstractions but functionally produces the correct results. The same may happen with your sqrt(-1) example, it is a bad idea from a modularity standpoint but may be functionally correct.

    If you want to talk about if that is the case for the browser selection, well, I am glad you agree that determining if the implementation of the JS quicksort routine causes the bug (or if it is something else) would be a good idea. Unfortunately the author of the article was happy to jump to premature (although not unreasonable) conclusions.

    And don't worry about me being a programmer. My code is quite reliable and in fact I do a lot of work on software reliability and correctness.

  123. Re:Might be a mistake but not where Rob is pointin by IWannaBeAnAC · · Score: 1

    You do realize there is a difference between code that is dangerous (but technically correct) and code that is actually buggy. As per my quicksort example. Dangerous, but correct.

    I don't think that there is such a thing as "dangerous (but technically correct)". Given a specific implementation, it may just happen to do what you want it to, if you supply a specially crafted input that violates the spec. I would call that dangerous, incorrect, but may happen to work on a specific implementation. There is no reason to expect that it will continue to work on the next release of the software.

    It would be fair enough, if you wrote your own algorithm, lets call it marron_sort(), that has the spec:

    marron_sort(array, comp):
    Precondition: none
    Postcondition: array' is permuted according to the QuickSort algorithm as specified on Wikipedia, as retrieved on 1st March 2010

    This algorithm serves (at least) two purposes: (1) given a comparitor defining a strict weak ordering, it sorts the array. (2) if the comparitor returns unbiased coin tosses, then the array is permuted by an unbiased random shuffle.

    I hope that you can agree that this is a rather weird specification! In any event, this is nothing like the actual specification of Javascript sort(). The fact that there is one theoretical implementation that does what you want when given invalid input doesn't mean that it is in any way reasonable to expect the same behavior for random implementation X. Especially since the 'one theoretical implementation' in this case is non-optimal.

    Calling my quicksort routine with an invalid compare function clearly violates the intent of the contract abstractions but functionally produces the correct results.

    No it doesn't. The QuickSort specifies a postcondition that on algorithm exit, the array is sorted. There is no way that a non-sorted array can be considered 'correct'.

    The same may happen with your sqrt(-1) example, it is a bad idea from a modularity standpoint but may be functionally correct.

    Huh what? Firstly, what does 'modularity' have to do with it? And secondly, can you explain how calling sqrt(-1) 'may be functionally correct' ? What do you expect it do to?

    If you want to talk about if that is the case for the browser selection, well, I am glad you agree that determining if the implementation of the JS quicksort routine causes the bug (or if it is something else) would be a good idea.

    One more time, for the road: the bug was caused by some n00b programmer calling the Javascript sort function with an invalid comparison function. I don't understand why you seem to be trying to blame the implementor of the Javascript sort function, when the sort function is completely correct and obeys the specification! There is probably no browser in existence that would actually implement sort in the way that you apparently think it should be. If you really think that strongly about it, I suggest you talk to the W3C. I don't expect they'll pay any attention to you though.

    Unfortunately the author of the article was happy to jump to premature (although not unreasonable) conclusions.

    What? Are you on drugs? Rob wrote a test program, demonstrated that the code written by the MS programmer generated a non-uniform distribution, and verified that a correctly written random shuffle algorithm produces a uniform distribution, using the same test program. Rob also went through the code and identified the specific bug that caused the problem: incorrect use of the sort() function. How can you possibly call that a premature conclusion?

    During this thread, I have identified at least two sort fragments that are likely to be similar to code used in real-world implementations of the Javascript sort()

  124. Re:Might be a mistake but not where Rob is pointin by ma_luen · · Score: 1

    There are lots of dangerous but technically correct programs. In fact almost every program written is ill specified and most likely has methods that are used in ways that they were not initially intended.

    As for my example, I agree in a "good" program one would always use it according to the given specifications. Doing anything else is breaking modularity and invites errors when making later changes. If you fail to understand the difference between modularity/abstraction (using the semantics provided by the contracts) and correctness (producing desired results) then I cannot help you.

    No what Rob demonstrated was that replacing the call to sort made the error go away. But several things were changed here as well (most notably the random number generation and initial seeding were probably altered substantially). So, while he is right that calling sort to get a purmutation is a bad idea and he is (probably) right that the sort was the problem, this is never actually shown in the article. He just assumes that the bug went away so it must mean that the sort was the problem (but as I showed above this need not be the case).

    As for your concern for me, I doubt if my code has appeared on TheDailyWTF, but I do know that I recently had some of my work in the ACM proceedings of "Verification Model Checking and Abstact Interpetation" on modeling the semantics of programs for later verification applications. So, I do know a bit about program correctness and specification. How about you?

  125. Re:Might be a mistake but not where Rob is pointin by IWannaBeAnAC · · Score: 1

    If you define correctness as "producing the desired results on one particular version of one particular platform", then you have a recipe for non-robust code that won't survive in the real world.

    No what Rob demonstrated was that replacing the call to sort made the error go away. But several things were changed here as well (most notably the random number generation and initial seeding were probably altered substantially).

    Damn, I've been wasting my time. Now I know you didn't properly read the article. He includes the test programs he used. They are pretty short, and easy to verify that there is no difference at all in the random number generation, nor in initial seeding (whatever that is supposed to mean - you seed the random generator once at the start of the program [or better still, when the machine is powered on], and never touch it afterwards). What a waste of a couple of hours.

    So, while he is right that calling sort to get a purmutation is a bad idea and he is (probably) right that the sort was the problem, this is never actually shown in the article. He just assumes that the bug went away so it must mean that the sort was the problem (but as I showed above this need not be the case).

    Not worth responding to, just reinforces that you never looked at the source code.

    As for your concern for me, I doubt if my code has appeared on TheDailyWTF, but I do know that I recently had some of my work in the ACM proceedings of "Verification Model Checking and Abstact Interpetation" on modeling the semantics of programs for later verification applications. So, I do know a bit about program correctness and specification. How about you?

    Conference proceedings don't count for much. I can't see any evidence that you know anything about devloping robust programs. Not that I'd expect you to, it is quite a different game to developing verification software anyway (although if the verification software itself needs tp be robust, then we have a problem).

  126. Re:What? Why not? by Anonymous Coward · · Score: 0

    Or if you're really unlucky it could sit there sorting them forever.

    No, qsort will always abort, no matter how bad you chose your random comparisons. It may need N^2 comparisons and produce an order that is unexpected and non-uniformly distributed, but otherwise it's a pretty safe bet.

  127. Where there is no pain there is no burn by SuperKendall · · Score: 1

    Where is the heartburn about Mac or Ubuntu with all of the stuff they load onto their systems and then prevent one from loading outside stuff??

    What the hell are you talking about?

    Yes a Mac ships with Safari. But it's only a click away to install Firefox - many do.

    Macs hardly ship with anything, that is the appeal... and there is ZERO prevention of loading outside stuff. Same with Ubuntu (though that does ship with a lot more preloaded stuff).

    The fact is that Windows is a monopoly, and for the good of the web Europe has decided Microsoft needs to allow clear browser choice. Frankly I don't give a damn which browser users choose, the important thing is that it's not all IE so that web sites have to be developed to a standard, not a browser.

    I actually do not support Microsoft being forced to do this, but since they are so forced let's do it right.

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley
  128. Re:Might be a mistake but not where Rob is pointin by ma_luen · · Score: 1

    If you define correctness as "producing the desired results on one particular version of one particular platform", then you have a recipe for non-robust code that won't survive in the real world.

    I think defining correctness as "producing the desired results is pretty reasonable. Sure correct doesn't mean robust, but they are different things and this discussion has been about correctness.

    Damn, I've been wasting my time. Now I know you didn't properly read the article. He includes the test programs he used. ...
    Not worth responding to, just reinforces that you never looked at the source code

    Yeah, I looked at the code. He replaces the sort says the bug is gone, must be a bug in how the sort is used. Sure seems likely but where is the actual bug. If we are going to spend the time giving a case study of a bug I think showing exactly there the bug is and why it is matters. But I suppose reasonable people can disagree.

    The main thing this discussion has shown is the existence of different metrics for program quality, i.e. an error and a bad design, one is wrong the other is undesirable but correct (at least for the current program). Both are bad but in different ways and need to be handled using different techniques.

    Conference proceedings don't count for much. I can't see any evidence that you know anything about devloping robust programs. Not that I'd expect you to, it is quite a different game to developing verification software anyway (although if the verification software itself needs tp be robust, then we have a problem).

    If that is your opinion. But I should note that IBM, Microsoft, Mozilla, etc. spend a fair bit of money to sponsor and send people to these things. So someone apparently thinks these proceedings count for a fair bit (and companies that care a lot about building robust systems).

    I'll leave my part at that.

  129. Re:What? Why not? by Anonymous Coward · · Score: 0

    If they had assigned a random value to each element and sorted by that value the result would have been truly random as the value associated with each element would have been consistent.

    As another poster above pointed out, that only works if your "random values" are unique.

      -AC

  130. Re:Might be a mistake but not where Rob is pointin by IWannaBeAnAC · · Score: 1

    I think defining correctness as "producing the desired results is pretty reasonable. Sure correct doesn't mean robust, but they are different things and this discussion has been about correctness.

    No, from an engineering point of view it isn't reasonable at all. I can see where you are coming from, and that you want to have a definition of correctness that your verification tools can use, so you can prove that some piece of software is or isn't 'correct'. I'm sure that makes for great marketing! But without formal verification against a specification, there is no way to certify that the design is correct against even the smallest change in the system. I'm going to harp on about this because its an important point that you might not be able to see from your ivory tower[*].

    Lets take a more traditional engineering example: a bridge. The bridge designer comes up with a set of specifications for each part, and a bunch of people build the parts and deliver them, and some more people put the bridge together. Now, suppose that the person making one particular cable screws it up, and instead of being able to withstand a force of 100,000N, it can only stand a force of 1,000N before breaking. According to the design specification of the bridge, this cable must be able to withstand the full 100,000N when undergoing extreme stresses (high winds, lots of traffic, etc). Now also suppose that by a lucky coincidence, the person making the support structure elsewhere in the bridge did an excellent job and over-engineered their components such that, even under high stresses, the cable is never tested beyond 1,000N, instead the forces are distributed among other parts of the bridge. The result is, the bridge doesn't fall down.

    I'm betting at this point that you would say that the bridge is correct. After all, your verification tools will throw some inputs (traffic, weather, etc) at the bridge, covering all of the extremes and corner cases, and it doesn't fall down, so it must be correct!

    The only problem is, that there is a good chance a whole bunch of people will die, sooner or later. Eg, suppose that later on when the bridge needs some maintenance on some of the supports, a different contractor is brought in, who looks at the spec, builds the component, and puts it in the bridge. He can do this, while still satisfying the specification, in such a way that suddenly the cable, that previously only had 1,000N force on it, now has the full design specification of 100,000N and the cable promptly snaps. You are still asking "where is the actual bug?". If you cannot see where the bug is, I think there is no hope.

    The above example is a very close analogy to the Javascript code. The bridge support structure is the Javascript standard library, and the cable is the Microsoft browser choice web page. The code in the web page doesn't meet the specification, but due to a lucky accident, it happens to work. Umm, except that it doesn't: on none of the browsers tested, does it actually work. The only way it would work is if the Javascript sort function was implemented in the precise way that you seem to advocate, a naive QuickSort that just happens to have the property that if you violate the precondition in a particular way, the algorithm will violate its postcondition in a particular way that coincides with what you actually want. If you want to call that correct then I guess no one can stop you, but when you sell your verification software to customers you should make it very clear how you are defining 'correct'. I rather suspect their definitions will disagree!

    This is why, in some schools of thought, it is considered a serious bug if a function does anything sensible with input beyond what is specified in the precondition. It can hide bugs elsewhere in the code, because it opens up the possibility that you accidentally misuse a function, but that misuse is hidden and is likely to surface and bite you when you least expect it. For a simple exa

  131. Re:Might be a mistake but not where Rob is pointin by IWannaBeAnAC · · Score: 1

    I think defining correctness as "producing the desired results" is pretty reasonable. Sure correct doesn't mean robust, but they are different things and this discussion has been about correctness.

    I agree that correctness and robustness are different things. Robustness is about flexibility of a specification. Non-robust code (and programs) have very tight specifications and are useful only only under a narrow set of circumstances.

    Corretness is (in my, and I think fairly common definition) a question of whether the specification is implemented correctly. From an architectural point of view, correctness may be applied to the specification itself, so one can talk about correctness of the specification, but that isn't what I'm talking about here. Correctness of the program is purely about bugs (or hopefully lack of!) in the software implementing the specification.

    According to this definition, it is possible to have an incorrect program that still produces correct results. This may happen, for example, if the program calls a standard library function incorrectly (ie, violating a precondition), but the implementation of that function is such that it just happens to work anyway. Such a piece of software may still be useful, no denying that, but I assert that it is still not correct. A formal proof will show that it is incorrect because internal invariants will not be met. In some cases it may be possible to devise a new set of specifications (preconditions and invariants) such that the program is correct. But that means that you need to be able to modify the specifications, and obviously for something like a standard library function you have no control over the external specification.

  132. Wikipedia page for shuffling by Anonymous Coward · · Score: 0

    I just put a better Python implementation in the wikipedia page for fisher-yates shuffle, adapted from the Python standard library. Can I get a code review?

    http://en.wikipedia.org/wiki/Fisher–Yates_shuffle

  133. Re:BROWZAAAAZ!! by Anonymous Coward · · Score: 0
    Why is this modded "Troll"?

    It's exactly what's happened.

    MS marketing's Mod Squad is ruining Slashdot.

  134. Random seed to fix? by moeng · · Score: 1
    From the article:

    Sorting requires a self-consistent definition of ordering.

    The article implies the root of the problem is because it introduces inconsistency in comparisons. Could this be fixed by generating a random seed, then replacing all calls to Math.random() with Math.random(seed)?

  135. Good Enough by JobyOne · · Score: 1

    You cannot just throw Math.random() at a problem and stir the pot and expect good results

    You can expect good enough results though. This particular application isn't exactly rocket science or cryptography, slightly non-random is good enough for me.

    Granted, it's a silly mistake to make. I would imagine they didn't put their best and brightest on this one though. Interns, anyone?

    --
    Porquoi?